├── .gitignore ├── LICENSE.md ├── README.md ├── alsa └── alsavolctrl ├── bspwm ├── bspfullscreen ├── bsphide ├── bspreceptacle ├── bspswallow ├── bspunhide ├── cleanfullscreen ├── crystal ├── fixdualhead ├── tabc └── tabdmenu ├── checkweather ├── color10bit ├── color256 ├── comp ├── cpcolor ├── crf ├── cryptocheck ├── cryptonotify ├── dcalc ├── dman ├── dmonitor ├── dmtpfs ├── dmusic ├── dragon ├── cpdragon ├── dlfile └── mvdragon ├── dvideospace ├── editor ├── encode ├── fixcam ├── flash ├── gem ├── i3 ├── i3battery ├── i3cpu ├── i3disk ├── i3ip ├── i3memory ├── i3speedtest ├── i3temp ├── i3torrents ├── i3volume ├── i3weather └── i3wifi ├── inf ├── joshuto ├── kdenchapters ├── killandnotify ├── launchspt ├── lemonbar ├── launchlemon ├── lemonconfig ├── lemoncpu ├── lemoncputemp ├── lemonpackages └── lemontime ├── lemonworkspaces ├── lf └── preview ├── luc ├── mepapemaker.sh ├── mkscript ├── mousemove ├── mp3convert ├── multimonitor ├── nodechildren ├── nodeclass ├── nodename ├── notifycrypto ├── opnbrow ├── opout ├── pfetch ├── polybar ├── launchpolybar ├── polybattery ├── polycpu ├── polypulsevolume ├── polysubs ├── polytemp ├── polytempamd └── reloadpolybar ├── prompt ├── pulse ├── pulsedevices └── pulsevolctrl ├── pulseupdate ├── pyshell ├── reflemon ├── rootid ├── rssreader ├── sch ├── screenshot ├── shfm ├── smenutest ├── songname ├── songnotification ├── soundboard ├── stabmux ├── streammusic ├── streamtime ├── stripspace ├── timestamps ├── toggleprogram ├── toggletouch ├── torque ├── transmission ├── notifytorrents ├── tordone ├── transadd └── transclr ├── tuxtalk ├── updatepackages ├── updatesubs ├── videospace ├── view ├── virmon └── z.lua /.gitignore: -------------------------------------------------------------------------------- 1 | blog 2 | bookmenu 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Script Descriptions 2 | 3 | ## ALSA Scripts 4 | 5 | ### alsavolctrl 6 | 7 | Changes the volume of tracks in alsa 8 | 9 | #### Dependencies 10 | 11 | + amixer 12 | + i3volume 13 | 14 | ## BSPWM Scripts 15 | 16 | ### bspfullscreen 17 | 18 | Simple script to toggle a node to fullscreen mode in bspwm 19 | 20 | #### Dependencies 21 | 22 | + bspc 23 | + bsphide 24 | + bspunhide 25 | 26 | ### bsphide 27 | 28 | Simple script to hide all the nodes on a desktop in bspwm 29 | 30 | #### Dependencies 31 | 32 | + bspc 33 | + pgrep 34 | + polybar (optional) 35 | 36 | ### bspunhide 37 | 38 | Simple script to show all the nodes on a desktop in bspwm 39 | 40 | #### Dependencies 41 | 42 | + bspc 43 | + pgrep 44 | + polybar (optional) 45 | 46 | ### tabc 47 | 48 | Adds/removes a node into/out of an instance of tabbed, to allow for tabbing in bspwm 49 | 50 | Modified version of [this script](https://gist.github.com/jpentland/468a42c172eb607bb950f5d00606312c) 51 | 52 | #### Dependencies 53 | 54 | + bspc 55 | + xdotool 56 | + xprop 57 | + xwininfo 58 | 59 | ## i3 Scripts 60 | 61 | ### i3battery 62 | 63 | Shows the battery percentage formatted to show in i3blocks 64 | 65 | #### Dependencies 66 | 67 | + acpi 68 | + perl 69 | 70 | ### i3cpu 71 | 72 | Shows the cpu usage formatted to show in i3blocks 73 | 74 | #### Dependencies 75 | 76 | + mpstat 77 | + perl 78 | 79 | ### i3disk 80 | 81 | Shows the disk usage formatted to show in i3blocks 82 | 83 | #### Dependencies 84 | 85 | + df 86 | 87 | ### i3ip 88 | 89 | Shows the ip address of the computer formatted to show in i3blocks 90 | 91 | #### Dependencies 92 | 93 | + inet 94 | + ip 95 | + xclip 96 | 97 | ### i3memory 98 | 99 | Shows the memory usage formatted to show in i3blocks 100 | 101 | #### Dependencies 102 | 103 | + mem 104 | 105 | ### i3speedtest 106 | 107 | Shows the network performance formatted to show in i3blocks 108 | 109 | #### Dependencies 110 | 111 | + speedtest-cli 112 | 113 | ### i3temp 114 | 115 | Shows the cpu temperate formatted to show in i3blocks 116 | 117 | #### Dependencies 118 | 119 | + acpi 120 | 121 | ### i3torrents 122 | 123 | Shows the torrents available in transmission formatted to show in i3blocks 124 | 125 | #### Dependencies 126 | 127 | + transmission-remote 128 | 129 | ### i3volume 130 | 131 | Shows the volume for alsa formatted to show in i3blocks 132 | 133 | #### Dependencies 134 | 135 | + amixer 136 | 137 | ### i3weather 138 | 139 | Shows the current weather in Adelaide formatted to show in i3blocks 140 | 141 | #### Dependencies 142 | 143 | + curl 144 | 145 | ### i3wifi 146 | 147 | Shows the current wifi connectivity level formatted to show in i3blocks 148 | 149 | ## Lemonbar Scripts 150 | 151 | ### launchlemon 152 | 153 | Launches an instance of lemonbar 154 | 155 | #### Dependencies 156 | 157 | + lemonbar 158 | + lemonconfig 159 | 160 | ### lemonconfig 161 | 162 | Outputs a configuration for lemonbar 163 | 164 | #### Dependencies 165 | 166 | + acpi 167 | + bspc 168 | + pulsevolume 169 | + xdotool 170 | 171 | ## Lf Scripts 172 | 173 | ### preview 174 | 175 | Preview script built for use with lf and fzf 176 | 177 | #### Dependencies 178 | 179 | + glow (markdown) 180 | + highlight 181 | + mediainfo (png, jpg, mp4, etc) 182 | + pdftotext (pdf) 183 | + pistol 184 | + tar (tar) 185 | + unrar (rar) 186 | + zipinfo (zip) 187 | 188 | ## Polybar Scripts 189 | 190 | ### launchpolybar 191 | 192 | Launches an instance of polybar 193 | 194 | #### Dependencies 195 | 196 | + killall 197 | + pgrep 198 | + polybar 199 | 200 | ### polybattery 201 | 202 | Shows battery percentage formatted to be shown in polybar 203 | 204 | #### Dependencies 205 | 206 | + acpi 207 | 208 | ### polycpu 209 | 210 | Shows the cpu usage formatted to be shown in polybar 211 | 212 | #### Dependencies 213 | 214 | + perl 215 | + mpstat 216 | 217 | ### polypulsevolume 218 | 219 | Shows the pulse volume formatted to be shown in polybar 220 | 221 | #### Dependencies 222 | 223 | + pulsedevices 224 | 225 | ### polytemp 226 | 227 | Shows the temperature of the CPU formatted to be shown in polybar 228 | 229 | #### Dependencies 230 | 231 | + acpi 232 | 233 | ### reloadpolybar 234 | 235 | Reloads an instance of polybar or launches it if it's not already running 236 | 237 | #### Dependencies 238 | 239 | + pidof 240 | + polybar 241 | 242 | ## Pulse Audio Scripts 243 | 244 | ### pulsedevices 245 | 246 | Lists out the pulse devices and volume data 247 | 248 | #### Dependencies 249 | 250 | + pactl 251 | 252 | ### pulsevolctrl 253 | 254 | Modifies the volumes level of a pulse sink 255 | 256 | #### Dependencies 257 | 258 | + pactl 259 | 260 | ## Transmission Scripts 261 | 262 | ### notifytorrents 263 | 264 | Hacky script to list out all the torrents in transmission 265 | 266 | #### Dependencies 267 | 268 | + pgrep 269 | + notify-send 270 | + transmission-remote 271 | 272 | ### tordore 273 | 274 | Sends a notification that a torrent has completed in transmission 275 | 276 | #### Dependencies 277 | 278 | + polybar (bar) 279 | + notify-send 280 | 281 | ### transadd 282 | 283 | Sends a notification that a torrent has been added to transmission 284 | 285 | #### Dependencies 286 | 287 | + pgrep 288 | + polybar (bar) 289 | + transmission-remote 290 | 291 | ### transclr 292 | 293 | Clears out all completed torrents from transmission 294 | 295 | #### Dependencies 296 | 297 | + transmission-remote 298 | + pidof 299 | + polybar (bar) 300 | 301 | ### transrss 302 | 303 | Opens transmission-rss in the background 304 | 305 | #### Dependencies 306 | 307 | + transmission-rss 308 | 309 | ## Other Scripts 310 | 311 | ### comp 312 | 313 | General handler script for compiling various file types 314 | 315 | ### Dependencies 316 | 317 | + readlink 318 | + pandoc 319 | + php 320 | 321 | ### crf 322 | 323 | Generates a template react file 324 | 325 | ### dfm 326 | 327 | Dmenu based file manager 328 | 329 | Sourced from [this repo](https://github.com/huijunchen9260/dmenufm) 330 | 331 | ### dfm-ext 332 | 333 | Extraction script for dmenufm 334 | 335 | Sourced from [this repo](https://github.com/huijunchen9260/dmenufm) 336 | 337 | ### dlfile 338 | 339 | Provides the ability to download a file by dropping it into a window 340 | 341 | #### Dependencies 342 | 343 | + curl 344 | + dragon 345 | 346 | ### dman 347 | 348 | Searches the man page data for an entry entered from a dmenu prompt 349 | 350 | #### Dependencies 351 | 352 | + dmenu 353 | 354 | ### encode 355 | 356 | Performs HTML encoding on a string, there's probably a better way to do this 357 | 358 | ### extramonitor 359 | 360 | Toggle on/off an external monitor and attempt to fix overscan issues 361 | 362 | #### Dependencies 363 | 364 | + notify-send 365 | + xrandr 366 | 367 | ### fixcam 368 | 369 | Sets my C920 with my webcam settings 370 | 371 | #### Dependencies 372 | 373 | + v4l2-ctl 374 | 375 | ### importandroid 376 | 377 | Imports all the files of a specified type from an android device between 378 | a specific time frame 379 | 380 | #### Dependencies 381 | 382 | + notify-send 383 | + xargs 384 | 385 | ### keys 386 | 387 | Uses xev to output the codes of the keys pressed 388 | 389 | Sourced from the [arch wiki](https://wiki.archlinux.org/index.php/Keyboard_input#Identifying_keycodes_in_Xorg) 390 | 391 | #### Dependencies 392 | 393 | + xev 394 | 395 | ### killandnotify 396 | 397 | Kills an application and sends a notification saying it was killed 398 | 399 | #### Dependencies 400 | 401 | + notify-send 402 | + pgrep 403 | 404 | ### mepapemaker.sh 405 | 406 | Turns any wallpaper into an arch wallpaper 407 | 408 | Source from [this repo](https://gitlab.com/SillyPill/arch-pape-maker) 409 | 410 | ### mkscript 411 | 412 | Generates a new script file in my scripts directory 413 | 414 | ### mntandroid 415 | 416 | Handler script for mounting and unmounting an android device 417 | 418 | #### Dependencies 419 | 420 | + simple-mtpfs 421 | + fusermount 422 | 423 | ### mntandroid 424 | 425 | Mounts an android device to the cell directory 426 | 427 | #### Dependencies 428 | 429 | + fusermount 430 | + simple-mtpfs 431 | 432 | ### multimonitor 433 | 434 | Wrapper script for extramonitor to select the way mode to use the extramonitor 435 | in 436 | 437 | #### Dependencies 438 | 439 | + dmenu 440 | + xargs 441 | 442 | ### nodechildren 443 | 444 | Lists the children of window 445 | 446 | #### Dependencies 447 | 448 | + xwininfo 449 | 450 | ### nodeclass 451 | 452 | Prints out the window class of a window 453 | 454 | #### Dependencies 455 | 456 | + xprop 457 | 458 | ### openterminalin 459 | 460 | Cd into a directory using dmenufm 461 | 462 | #### Dependencies 463 | 464 | + dfm 465 | 466 | ### opnbrow 467 | 468 | Handler script for opening different browsers 469 | 470 | #### Dependencies 471 | 472 | + firefox 473 | 474 | ### opout 475 | 476 | General handler script for opening the output for a file 477 | 478 | ### pfetch 479 | 480 | POSIX compliant version of neofetch 481 | Source from [this repo](https://github.com/dylanaraps/pfetch) 482 | 483 | ### prompt 484 | 485 | Simple confirmation prompt using dmenu 486 | 487 | #### Dependencies 488 | 489 | + dmenu 490 | 491 | ### pyshell 492 | 493 | Opens a python shell in a prompt, to run simple scripts 494 | 495 | #### Dependencies 496 | 497 | + dmenu 498 | + python 499 | + notify-send 500 | + xargs 501 | 502 | ### rootid 503 | 504 | Outputs the id of the root window 505 | 506 | #### Dependencies 507 | 508 | + xwininfo 509 | 510 | ### sch 511 | 512 | Browser independent search engine querying 513 | 514 | #### Dependencies 515 | 516 | + dmenu 517 | + opnbrow 518 | 519 | ### screenshot 520 | 521 | Handler script to take a screenshot with maim 522 | 523 | ### stabmux 524 | 525 | Wrapper script to open up st in tabbed and tmux 526 | 527 | #### Dependencies 528 | 529 | + st 530 | + tabbed 531 | + tmux 532 | 533 | ### tabdmenu 534 | 535 | Provides a simple interface through dmenu to open common tabbing applications 536 | 537 | #### Dependencies 538 | 539 | + nodeclass 540 | + tabbed 541 | + xdotool 542 | 543 | ### toggleprogram 544 | 545 | Provides the ability to toggle any program 546 | 547 | #### Dependencies 548 | 549 | + killandnotify 550 | + pgrep 551 | 552 | ### toggletouch 553 | 554 | Toggles my laptops touchpad 555 | 556 | #### Dependencies 557 | 558 | + notify-send 559 | + xargs 560 | + xinput 561 | 562 | ### updatepackages 563 | 564 | Opens up pacman in a terminal to update my packages 565 | 566 | #### Dependencies 567 | 568 | + pacman 569 | 570 | ### view 571 | 572 | Provides a method to generate read only versions of files 573 | 574 | #### Dependencies 575 | 576 | + libre 577 | 578 | ### virmon 579 | 580 | Hacky script to test out virtual monitors 581 | 582 | #### Dependencies 583 | 584 | + xrandr 585 | 586 | -------------------------------------------------------------------------------- /alsa/alsavolctrl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Changes the volume level of an audio track 3 | # Signals an the status bar to update 4 | 5 | if [ "$1" = "All" ]; then 6 | if [ "$2" = "mute" ]; then 7 | volume="$(i3volume)" 8 | 9 | if [ ! "$(echo "$volume" | grep -q "mute")" ]; then 10 | amixer set "Master" "mute" 11 | amixer set "Headphone" "mute" 12 | amixer set "Speaker" "mute" 13 | else 14 | amixer set "Master" "unmute" 15 | amixer set "Headphone" "unmute" 16 | amixer set "Speaker" "unmute" 17 | fi 18 | fi 19 | else 20 | amixer set "$1" "$2" 21 | fi 22 | 23 | #pkill -SIGRTMIN+1 i3blocks 24 | polybar-msg hook volume 1 25 | -------------------------------------------------------------------------------- /bspwm/bspfullscreen: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple script to toggle a node to fullscreen mode in bspwm 3 | if [ -z "$(bspc query -N -n .focused.fullscreen -d focused)" ]; then 4 | bspc node focused.tiled -t fullscreen 5 | else 6 | bspc node focused.fullscreen -t tiled 7 | fi 8 | 9 | -------------------------------------------------------------------------------- /bspwm/bsphide: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple script to hide all the nodes on a desktop in bspwm 3 | NODES=$(bspc query -N -n .tiled -d focused) 4 | 5 | # Hide bar if it's running 6 | if pgrep "polybar"; then 7 | polybar-msg cmd hide 8 | fi 9 | 10 | for node in $NODES; do 11 | bspc node $node -g hidden=on 12 | done 13 | -------------------------------------------------------------------------------- /bspwm/bspreceptacle: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ID=$(bspc query -N -n) 3 | bspc node $ID -n $(bspc query -N -n .leaf.\!window) 4 | -------------------------------------------------------------------------------- /bspwm/bspswallow: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Get class of a wid 4 | get_class() { 5 | Id=$1 6 | if [ -z $Id ]; then 7 | echo "" 8 | else 9 | xprop -id "$Id" | sed -n '/WM_CLASS\|WM_COMMAND/s/.*"\(.*\)".*/\1/p' 10 | fi 11 | } 12 | 13 | swallow() { 14 | SwallowerId=$1 15 | SwallowingId=$(bspc query -N -n prev) 16 | AddedToDesktop=$2 17 | LastTerminalDesktop=$(bspc query -D -n $SwallowingId) 18 | 19 | if [ $AddedToDesktop = $LastTerminalDesktop ]; then 20 | grep "^$(get_class $SwallowerId)$" ~/.config/bspwm/noswallow && return 21 | grep "^$(get_class $SwallowerId)$" ~/.config/bspwm/terminals && return 22 | grep "^$(get_class $SwallowingId)$" ~/.config/bspwm/terminals || return 23 | echo $SwallowerId $SwallowingId >> /tmp/swallowids 24 | bspc node $SwallowingId --flag hidden=on 25 | fi 26 | } 27 | 28 | spit() { 29 | SpitterId=$1 30 | grep "^$SpitterId" /tmp/swallowids || return 31 | SpittingId=$(grep "^$SpitterId" /tmp/swallowids | head -n1 | awk '{print $2}') 32 | bspc node $SpittingId --flag hidden=off 33 | bspc node $SpittingId -f 34 | sed -i "/^$SpitterId/d" /tmp/swallowids 35 | } 36 | 37 | bspc subscribe node_add | while read -r Event Monitor Desktop Ip Node 38 | do 39 | swallow $Node $Desktop 40 | done & 41 | 42 | bspc subscribe node_remove | while read -r Event Monitor Desktop Node 43 | do 44 | spit $Node 45 | done & 46 | -------------------------------------------------------------------------------- /bspwm/bspunhide: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple script to hide all he nodes on a desktop 3 | 4 | NODES=$(bspc query -N -n .hidden -d focused) 5 | 6 | # Show bar if it's running 7 | if pgrep "polybar"; then 8 | polybar-msg cmd show 9 | fi 10 | 11 | for node in $NODES; do 12 | bspc node $node -g hidden=off 13 | done 14 | -------------------------------------------------------------------------------- /bspwm/cleanfullscreen: -------------------------------------------------------------------------------- 1 | /home/brodie/repos/cleanfullscreen/cleanfullscreen -------------------------------------------------------------------------------- /bspwm/crystal: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Status Bar 4 | [ "$STATUS_BAR" ] || export STATUS_BAR=polybar-bar_DisplayPort-0 5 | 6 | hidden_windows=/tmp/crystal_0$(wmctrl -d | grep "\*" | cut -d ' ' -f 1) 7 | hidden_desktops=/tmp/crystal_1$(wmctrl -d | grep "\*" | cut -d ' ' -f 1) 8 | mode="$hidden_windows"_mode 9 | 10 | hide_nodes() { 11 | xdo id -rd | tee "$hidden_windows" 12 | bspc query -D -d focused | tee "$hidden_desktops" 13 | while read p; do 14 | bspc node "$p" -g hidden=on 15 | done < "$hidden_windows" 16 | bspc node -t fullscreen 17 | } 18 | 19 | unhide_nodes() { 20 | while read p; do 21 | 22 | if [ ! "$(grep "$p" /tmp/swallowids | awk '{ print $2 }')" = "$p" ]; then 23 | bspc node "$p" -g hidden=off 24 | fi 25 | done < "$hidden_windows" 26 | bspc node -t tiled 27 | 28 | : > "$hidden_windows" 29 | : > "$hidden_desktops" 30 | } 31 | 32 | hide_bar() { 33 | xdo hide -a $STATUS_BAR 34 | } 35 | 36 | show_bar() { 37 | xdo show -a $STATUS_BAR 38 | } 39 | 40 | case $1 in 41 | # Used to enter fullscreen mode 42 | --fullscreen) 43 | if [ -s "$mode" ]; then 44 | : > "$mode" 45 | unhide_nodes 46 | show_bar 47 | else 48 | echo mono > "$mode" 49 | hide_nodes 50 | hide_bar 51 | fi 52 | ;; 53 | 54 | # Used to send a node to another desktop 55 | --send) 56 | bspc node -d $2 57 | show_bar 58 | unhide_nodes 59 | ;; 60 | 61 | 62 | # Used when focusing on another desktop 63 | --focus) 64 | bspc desktop -f $2 65 | hidden_desktops=/tmp/crystal_1$(wmctrl -d | grep "\*" | cut -d ' ' -f 1) 66 | if [ "$(cat $hidden_desktops)" = "" ]; then 67 | show_bar 68 | else 69 | hide_bar 70 | fi 71 | reflemon 72 | ;; 73 | 74 | # Used when closing a node 75 | --close) 76 | xdo close 77 | unhide_nodes 78 | show_bar 79 | ;; 80 | *) : ;; 81 | 82 | esac 83 | -------------------------------------------------------------------------------- /bspwm/fixdualhead: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | HelpPage() { 4 | echo "Fix Dual Head Help Page 5 | -p name of the primary monitor 6 | -pd space seperated list of desktop names to be put on the primary monitor 7 | -s name of the secondary monitor 8 | -sd space seperated list of desktop names to be put on the secondary monitor 9 | -h show this help page" 10 | } 11 | 12 | for Value in "$@" 13 | do 14 | # Handle options 15 | case "$Value" in 16 | # Options requring arguments 17 | -p|-pd|-s|-sd) OptionSet=$Value ;; 18 | -h|--help) HelpPage; exit 0;; 19 | esac 20 | 21 | # Handle arguments 22 | if [ -n "$OptionSet" ]; then 23 | case "$OptionSet" in 24 | -p) PrimaryMonitor=$Value ;; 25 | -pd) PrimaryDesktops=$Value ;; 26 | -s) SecondaryMonitor=$Value ;; 27 | -sd) SecondaryDesktops=$Value ;; 28 | *) Err 1 "Invalid option set" ;; 29 | esac 30 | fi 31 | done 32 | 33 | # Add new desktops to secondary monitor 34 | for Value in $SecondaryDesktops 35 | do 36 | bspc monitor "$SecondaryMonitor" -a "$Value" 37 | done 38 | 39 | # Move primary desktops back to primary monitor 40 | for Value in $PrimaryDesktops 41 | do 42 | bspc desktop "$Value" -m "$PrimaryMonitor" 43 | done 44 | 45 | bspc desktop "Desktop" -r 46 | -------------------------------------------------------------------------------- /bspwm/tabc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Usage: 4 | # tabc.sh 5 | # Commands: 6 | # add - Add window to tabbedid 7 | # remove - Remove window from tabbedid 8 | # list - List all clients of tabbedid 9 | 10 | # 11 | # Functions 12 | # 13 | 14 | # Get wid of root window 15 | get_root_wid() { 16 | xwininfo -root | awk '/Window id:/{print $4}' 17 | } 18 | 19 | # Get children of tabbed 20 | get_clients() { 21 | id=$1 22 | xwininfo -id "$id" -children | sed -n '/[0-9]\+ \(child\|children\):/,$s/ \+\(0x[0-9a-z]\+\).*/\1/p' 23 | } 24 | 25 | # Get class of a wid 26 | get_class() { 27 | id=$1 28 | if [ -z "$id" ]; then 29 | echo "" 30 | else 31 | xprop -id "$id" | sed -n '/WM_CLASS/s/.*, "\(.*\)"/\1/p' 32 | fi 33 | 34 | } 35 | 36 | # 37 | # Main Program 38 | # 39 | 40 | cmd=$1 41 | 42 | case $cmd in 43 | add) 44 | wid=$3 45 | tabbedid=$(bspc query -N -n "$2") 46 | 47 | if [ -z "$tabbedid" ] || [ "$(get_class "$tabbedid")" != "tabbed" ]; then 48 | tabbed -c & 49 | bspc subscribe node_add | while read -r add 50 | do 51 | id=$(echo "$add" | awk '{print $5}') 52 | class="$(get_class "$id")" 53 | if [ "$class" = "tabbed" ]; then 54 | tabbedid=$id 55 | xdotool windowreparent "$wid" "$tabbedid" 56 | exit 0 57 | fi 58 | done 59 | xdotool windowreparent "$wid" "$tabbedid" 60 | else 61 | xdotool windowreparent "$wid" "$tabbedid" 62 | fi 63 | ;; 64 | remove) 65 | wid=$2 66 | tabbedid=$(bspc query -N -n focused) 67 | xdotool windowreparent "$wid" "$(get_root_wid)" 68 | ;; 69 | list) 70 | tabbedid=$2 71 | get_clients "$tabbedid" 72 | ;; 73 | esac 74 | -------------------------------------------------------------------------------- /bspwm/tabdmenu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Provides a simple interface to open common applications to use tabbing with 3 | 4 | windowid=$(xdotool getwindowfocus) 5 | 6 | newwindow() { 7 | command=$(dmenu < ~/.config/tabdmenu/apps) || exit 8 | 9 | # Bspwm only 10 | case "$command" in 11 | kitty|st) $command & ;; 12 | *) $TERMINAL -e "$command" & ;; 13 | esac 14 | bspc subscribe node_add | while read -r add 15 | do 16 | id=$(echo "$add" | awk '{print $5}') 17 | name=$(nodename "$id") 18 | if [ "$name" = "$command" ]; then 19 | newwindowid=$id 20 | xdotool windowreparent "$newwindowid" "$1" 21 | exit 0 22 | fi 23 | done 24 | 25 | # Generic wm 26 | # case "$command" in 27 | # kitty|st) $command & ;; 28 | # *) $TERMINAL -e $command & ;; 29 | # esac 30 | # sleep 0.1 31 | # newwindowid=$(xdotool getwindowfocus) 32 | # xdotool windowreparent $newwindowid $1 33 | } 34 | 35 | if [ "$(nodeclass "$windowid")" != "tabbed" ]; then 36 | # Generic wm 37 | # tabbed & 38 | # sleep 0.1 39 | # tabbedid=$(xdotool search --class tabbed | tail -n1) 40 | 41 | # Bspwm only 42 | tabbed -c & 43 | bspc subscribe node_add | while read -r add 44 | do 45 | id=$(echo "$add" | awk '{print $5}') 46 | class=$(nodeclass "$id") 47 | if [ "$class" = "tabbed" ]; then 48 | tabbedid=$id 49 | xdotool windowreparent "$windowid" "$tabbedid" 50 | newwindow "$tabbedid" 51 | exit 0 52 | fi 53 | done 54 | else 55 | newwindow "$windowid" 56 | fi 57 | 58 | -------------------------------------------------------------------------------- /checkweather: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | i3weather > ~/.cache/weather 3 | -------------------------------------------------------------------------------- /color10bit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | awk -v term_cols="${width:-$(tput cols || echo 80)}" 'BEGIN{ 3 | s="/\\"; 4 | for (colnum = 0; colnum255) g = 510-g; 9 | printf "\033[48;2;%d;%d;%dm", r,g,b; 10 | printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b; 11 | printf "%s\033[0m", substr(s,colnum%2+1,1); 12 | } 13 | printf "\n"; 14 | }' 15 | -------------------------------------------------------------------------------- /color256: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for i in {0..255} ; do 3 | printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i" 4 | if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then 5 | printf "\n"; 6 | fi 7 | done 8 | -------------------------------------------------------------------------------- /comp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # General handler for compiling files 3 | 4 | file=$(readlink -f "$1") 5 | base=$(echo "$file" | sed 's/\..*//') 6 | 7 | handlebang() { 8 | bang=$(head -n 1 "$file") 9 | case "$bang" in 10 | *!/bin/sh|*!/bin/bash|*!/bin/zsh) "$file" ;; 11 | *!/bin/perl) perl "$file" ;; 12 | *!/bin/python) python "$file" ;; 13 | *) echo "Can't compile" ;; 14 | esac 15 | } 16 | 17 | case "$1" in 18 | *.md) pandoc --filter pandoc-crossref "$file" -o "$base".pdf;; 19 | *.py) python "$file" ;; 20 | *.perl) perl "$file" ;; 21 | *) handlebang ;; 22 | esac 23 | -------------------------------------------------------------------------------- /cpcolor: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | colorpicker --short --one-shot --preview | xclip -selection clipboard 3 | 4 | -------------------------------------------------------------------------------- /crf: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to generate a templte react class 3 | printf "import React from \"react\";\n\nconst $1 = () => {\n\treturn
;\n};\n\nexport default $1;" > $(pwd)/$2/$1.js 4 | -------------------------------------------------------------------------------- /cryptocheck: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ShortName="BAT\nLBC\nTRX\nADA" 3 | 4 | if [ ! -d ~/.cache/crypto ]; then 5 | mkdir ~/.cache/crypto 6 | fi 7 | 8 | echo "$ShortName" | while read coin 9 | do 10 | price=$(curl rate.sx/1$coin) 11 | if [ $coin = "BAT" ]; then 12 | icon=🦁 13 | elif [ $coin = "LBC" ]; then 14 | icon=📖 15 | elif [ $coin = "TRX" ]; then 16 | icon=🔺 17 | elif [ $coin = "ADA" ]; then 18 | icon=⚛️ 19 | fi 20 | 21 | echo "$icon $coin: $price" > ~/.cache/crypto/$coin 22 | 23 | done 24 | 25 | date > ~/.cache/crypto/time 26 | 27 | -------------------------------------------------------------------------------- /cryptonotify: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | Output= 3 | for file in ~/.cache/crypto/* 4 | do 5 | if [ ! -z "$Output" ]; then 6 | if [ ! $(basename $file) = "time" ]; then 7 | Output="$Output\n$(cat $file)" 8 | fi 9 | else 10 | if [ ! $(basename $file) = "time" ]; then 11 | Output="$Output$(cat $file)" 12 | fi 13 | fi 14 | 15 | done 16 | 17 | Output="$Output\n$(cat ~/.cache/crypto/time)" 18 | notify-send "Crypto Prices" "$Output" 19 | -------------------------------------------------------------------------------- /dcalc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | Equation=$(echo "" | dmenu -n -p "Enter equation" | xargs -I % calc %) 3 | 4 | notify-send "Result" "$Equation" 5 | -------------------------------------------------------------------------------- /dman: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Dmenu prompt to easily search for a man page to open 3 | 4 | man "$(apropos --long "$1" | dmenu -i -l 10 | awk '{print $2, $1}' | tr -d '()')" 5 | -------------------------------------------------------------------------------- /dmonitor: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Toggle on/off an thirdal monitor, HDMI does not support audio over HDMI as it's pretending that it's DVI 3 | 4 | main="$1" 5 | second="$2" 6 | third="$3" 7 | 8 | extramonitor() { 9 | case "$1" in 10 | "disconnect") xrandr --output "$third" --off --output "$second" --off --output "$main" --auto ;; 11 | "main+4kthird") xrandr --output "$third" --mode 3840x2160 && xrandr --output "$main" --auto --output "$third" --right-of "$main" ;; 12 | "main+second") xrandr --output "$second" --mode 1920x1080 && xrandr --output "$main" --auto --output "$second" --left-of "$main" ;; 13 | "main+third") xrandr --output "$third" --mode 1920x1080 && xrandr --output "$main" --auto --output "$third" --right-of "$main" ;; 14 | "allthree") xrandr --output "$second" --mode 1920x1080 && xrandr --output "$third" --mode 1920x1080 && xrandr --output "$main" --auto --output "$second" --left-of "$main" --output "$third" --right-of "$main";; 15 | "duplicate") xrandr --output "$third" --set audio force-dvi --mode 1920x1080 && xrandr --output "$main" --auto --output "$third" --same-as "$main" ;; 16 | *) notify-send "Multi Monitor" "Unknown Operation" ;; 17 | esac 18 | } 19 | 20 | selection=$(printf "allthree\nmain+4kthird\nmain+third\nmain+second\ndisconnect\nduplicate" | dmenu -i -p "Monitor Configuration") 21 | extramonitor "$selection" && fixdualhead -pd "1 2 3 4 5 6 7" -p "$main" -s "$second" -sd "8 9 0" 22 | -------------------------------------------------------------------------------- /dmtpfs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | Dir=$XDG_DATA_HOME/cell/ 3 | 4 | # Make the cell directory if it doesn't exist 5 | if [ ! -d "$Dir" ]; then 6 | mkdir "$Dir" 7 | fi 8 | 9 | # Select device 10 | Devices=$(simple-mtpfs -l) 11 | 12 | if [ ! -n "$Devices" ]; then 13 | notify-send "No devices found" 14 | exit 15 | else 16 | Device=$(echo "$Devices" | dmenu -p "Select device:" || notify-send "No device selected") 17 | Id=${Device%%:*} 18 | Name=${Device##*: } 19 | if [ ! -d "$Dir$Name" ]; then 20 | mkdir "$Dir$Name" 21 | fi 22 | fi 23 | 24 | if [ ! -n "$(find "$Dir$Name" -maxdepth 0 -empty)" ]; then 25 | fusermount -u "$Dir$Name" && notify-send "Android Mount" "Device Unmounted" 26 | else 27 | simple-mtpfs --device "$Id" "$Dir$Name" && notify-send "Android Mount" "Device Mounted in $Dir$Name" 28 | fi 29 | -------------------------------------------------------------------------------- /dmusic: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | selection="$(cat ~/.config/streammusic/config | dmenu -i -p "Play Music")" 3 | streammusic "$selection" 4 | -------------------------------------------------------------------------------- /dragon/cpdragon: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | files=$(dragon-drag-and-drop -t -x) 3 | 4 | for file in $files 5 | do 6 | path=${file#file://} 7 | name=$(basename "$path") 8 | cp "$path" "$(pwd)/$name" 9 | done 10 | -------------------------------------------------------------------------------- /dragon/dlfile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Provides the ability to download a file by dropping it into a window 3 | 4 | url=$(dragon-drag-and-drop -t -x) 5 | 6 | if [ -n "$url" ]; then 7 | printf "File Name: " 8 | name="" 9 | while [ -z $name ] || [ -e $name ] 10 | do 11 | read -r name 12 | if [ -e "$name" ]; then 13 | printf "File already exists, overwrite (y|n): " 14 | read -r ans 15 | 16 | if [ "$ans" = "y" ]; then 17 | break 18 | else 19 | printf "File Name: " 20 | fi 21 | fi 22 | done 23 | 24 | # Download the file with curl 25 | [ -n "$name" ] && curl -o "$name" "$url" || exit 1 26 | else 27 | exit 1 28 | fi 29 | 30 | -------------------------------------------------------------------------------- /dragon/mvdragon: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | files=$(dragon-drag-and-drop -t -x) 4 | 5 | for file in $files 6 | do 7 | path=${file#file://} 8 | name=$(basename "$path") 9 | mv "$path" "$(pwd)/$name" 10 | done 11 | -------------------------------------------------------------------------------- /dvideospace: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | selection=$(printf "video\nstream" | dmenu -i -p "Video Layout") 4 | videospace $selection 5 | 6 | -------------------------------------------------------------------------------- /editor: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | $TERMINAL -e nvim "$1" 3 | -------------------------------------------------------------------------------- /encode: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Performs HTML encoding on a string for special characters up to ASCII 3 | 4 | echo "$1" | sed 's/%/%25/g;s/\s/%20/g;s/!/%21/g;s/"/%22/g;s/#/%22/g;s/\$/%24/g;s/&/%26/g;s/\x27/%27/g;s/)/%29/g;s/(/%28/g;s/\*/%2A/g;s/\+/%2B/g;s/,/%2C/g;s/-/%2D/g;s/\./%2E/g;s/\//%2F/g;s/:/%3A/g;s/;/%3B/g;s//%3E/g;s/\?/%3F/g;s/@/%40/g;s/]/%5D/g;s/\\/%5C/g;s/\[/%5B/g;s/\^/%5E/g;s/_/%5F/g;s/`/%60/g;s/}/%7D/g;s/|/%7C/g;s/{/%7B/g;s/~/%7E/g' 5 | -------------------------------------------------------------------------------- /fixcam: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple script to set my webcam settings 3 | # Key Light 35 4 | # Hair Light 30 5 | device=$(v4l2-ctl --list-devices | grep "C920" -A 1 | grep "/dev/video." -o) 6 | 7 | v4l2-ctl -d $device --set-ctrl=focus_auto=0 8 | v4l2-ctl -d $device --set-ctrl=exposure_auto=1 9 | v4l2-ctl -d $device --set-ctrl=white_balance_temperature_auto=0 10 | v4l2-ctl -d $device --set-ctrl=focus_absolute=20 11 | v4l2-ctl -d $device --set-ctrl=exposure_absolute=200 12 | v4l2-ctl -d $device --set-ctrl=saturation=128 13 | v4l2-ctl -d $device --set-ctrl=contrast=128 14 | v4l2-ctl -d $device --set-ctrl=sharpness=128 15 | v4l2-ctl -d $device --set-ctrl=white_balance_temperature=4500 16 | v4l2-ctl -d $device --set-ctrl=zoom_absolute=0 17 | v4l2-ctl -d $device --set-ctrl=brightness=120 18 | v4l2-ctl -d $device --set-ctrl=gain=50 19 | 20 | 21 | -------------------------------------------------------------------------------- /flash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #==============================================================# 3 | # 4 | # AUTHOR: 5 | # Bryan Jenks 6 | # - www.bryanjenks.xyz 7 | # - https://github.com/tallguyjenks/flash.sh 8 | # 9 | # SOURCE: 10 | # This file is based off of the one presented in this YouTube Video by nixcasts: 11 | # - https://www.youtube.com/watch?v=lX8jqo70r1I 12 | # 13 | # PURPOSE: 14 | # To have a command line flash card tool with minimal code, plain text input and output 15 | # 16 | # VISION: 17 | # The goal i have for this script is a basic level emulation of ANKI to where i have a way to 18 | # keep track of a score for each item in each selected deck so that it can pick from a selection 19 | # of the lowest scoring items and shuf them to the user for reenforcement of active recall. 20 | # 21 | # DEPENDENCIES: 22 | # fzf - https://github.com/junegunn/fzf 23 | # bat - https://github.com/sharkdp/bat 24 | #==============================================================# 25 | 26 | # USER CUSTOMIZABLE VARIABLES 27 | CARD_POOL_SIZE=10 # How large the pool size is for shuf to draw from 28 | SEARCH_DEPTH=999 # How many levels to recursively search for .csv's in .local/share/flash 29 | 30 | # ANSI FOREGROUND ESCAPE COLORS 31 | RED='\033[0;31m' 32 | LRED='\033[1;31m' 33 | YELLOW='\033[1;33m' 34 | GREEN='\033[0;32m' 35 | LGREEN='\033[1;32m' 36 | ORANGE='\033[0;33m' 37 | LGREY='\033[0;37m' 38 | WHITE='\033[1;37m' 39 | NC='\033[0m' # No Color 40 | # ANSI BACKGROUND ESCAPE COLORS 41 | WHITEBG='\033[1;47m' 42 | # FONT FORMAT EXCAPE CODES 43 | BOLD='\e[1m' 44 | 45 | # Remember User's Starting Directory 46 | PWD="$(pwd)" 47 | # Where Decks Are Located 48 | DIR="$HOME/.local/share/flash" 49 | # Where the example deck with be placed and named 50 | EXAMPLE_DECK="$DIR/deck.csv" 51 | # Track High score 52 | HIGH_SCORE="$DIR/.highscore" 53 | # Track number of cards reviewed per session 54 | REVIEW_LOG="$DIR/.reviews" 55 | # Iterator for Count of cards reveiwed 56 | COUNTER=0 57 | # Success message of setup process 58 | DIR_MADE_MSG=" 59 | Your ${LRED}~/.local/share/flash${NC} directory has been made and 60 | your ${ORANGE}deck.csv${NC} file is ready for you to enter your flashcard data 61 | " 62 | # User has .local/share directory but no decks inside 63 | NO_DECKS=" 64 | No decks were found, please make a new deck 65 | using ${ORANGE}:${NC} as a delimiter in a ${ORANGE}.csv${NC} file in 66 | the ${LRED}.local/share/flash${NC} directory. 67 | 68 | An example of a card: 69 | ${GREEN}Math:What is the square root of 4?:2:0${NC} 70 | " 71 | # The example flashcard deck to be made 72 | DECK_TEMPLATE="History:When was the declaration of independence signed?:1776:0 73 | Math:What is the square root of 4?:2:4 74 | Science:What is the charge of a proton?:Positive:2 75 | Philosophy:What was socrates known as?:The Gadfly of Athens:0 76 | Programming:What is the typical starting value of an array?:0:5 77 | History:What did Abraham Lincoln Typically Keep In his hat?:Mail:0 78 | Math:what is the first 2 decimal places of PI:3.14:4 79 | Science:What is the charge of an electron?:Negative:3 80 | Programming:What does OOP stand for?:Object Oriented Programming:2 81 | History:What did socrates drink to commit suicide?:Hemlock Tea:2 82 | Math:What is the equation for a slope of a line?:y=mx+b:4 83 | Science:What is the charge of a neutron?:Neutral:1 84 | Programming:What is Vim?:God's Text Editor:999 85 | History:What were the british known buy during the american revolution?:The redcoats:1 86 | Math:What is the value of this equation - log10(100)?:2:0 87 | Science:What are protons/neutrons/electrons made of?:quarks:5 88 | Programming:What does RAM stand for?:Random Access Memory:1 89 | History:What was the year 2000 also known as?:Y2K:0 90 | Math:What is the formula for mean?:Sum/count:4 91 | Science:What is cold?:The absense of heat:3 92 | Programming:What languages are the worst?:Proprietary:999 93 | History:When did man land on the moon?:1969:4 94 | Math:10^3=?:1000:1 95 | Science:The _____ ______ Project mapped all of man's genes.:Human Genome:3 96 | Programming:What is the best computer to program on?:Thinkpad:999 97 | History:When was flash.sh created?:April 2020:999 98 | Math:What do you call a number only divisible by itself and 1?:Prime:0 99 | Science:What is the distance between the Earth and Sol called?:An Astronomical Unit (AU):1 100 | Programming:Best operating system?:Arch, because BTW i run Arch:999" 101 | 102 | # Test if .local/share exists and wether to offer setup process 103 | if [ ! -d $DIR ];then 104 | echo -e "No ${LRED}.local/share/flash${NC} directory, make it? ${LGREEN}Y${NC}/${LRED}N${NC}" 105 | read RESPONSE 106 | case "$RESPONSE" in 107 | [QqNn]) exit ;; 108 | [Yy]) mkdir "$DIR" && touch {$EXAMPLE_DECK,$HIGH_SCORE,$REVIEW_LOG} && echo "$DECK_TEMPLATE" >> $EXAMPLE_DECK && echo -e "$DIR_MADE_MSG" && exit;; 109 | *) echo -e "invalid choice, please select either ${LGREEN}y${NC} or ${LRED}n${NC}" && exit ;; 110 | esac 111 | fi 112 | 113 | # go to the flashcard decks 114 | cd "$DIR" 115 | 116 | # If there are no flashcard decks available return user to starting location 117 | if [ "$(find -maxdepth 999 -iname "*.csv" | wc -l)" = 0 ]; then 118 | echo -e "$NO_DECKS" && cd "$PWD" && exit 119 | fi 120 | 121 | # if highscore file was removed, remake it. 122 | if [ ! -e "$HIGH_SCORE" ]; then 123 | touch "$HIGH_SCORE" 124 | fi 125 | 126 | # if reviewed file was removed, remake it. 127 | if [ ! -e "$REVIEW_LOG" ]; then 128 | touch "$REVIEW_LOG" 129 | fi 130 | 131 | # Show pretty FZF preview of decks using BAT 132 | DECK="$(find -maxdepth $SEARCH_DEPTH -iname '*.csv' | fzf --preview='bat --theme="Solarized (dark)" --style=numbers --color=always {} | head -500')" 133 | 134 | # If no deck is selected in fzf menu, return user to start location and exit 135 | if [ -z $DECK ]; then 136 | cd "$PWD" && exit 137 | fi 138 | 139 | main(){ 140 | IFS=$':'; read -a q <<<$(sort "$DECK" -n --field-separator=: --key=4 | head -n "$CARD_POOL_SIZE"| shuf -n 1) 141 | clear 142 | echo -e "${WHITEBG} Flash.sh - Flash Cards In Your Terminal ${NC}" 143 | echo -e "${ORANGE}${BOLD}Cards Reviewed:${BOLD}${NC}\t$COUNTER" 144 | echo -e " ${ORANGE}${BOLD}High Score:${BOLD}${NC}\t$(cat $HIGH_SCORE)" 145 | echo -e " ${ORANGE}${BOLD}Avg review:${BOLD}${NC}\t$(awk '{ sum += $7; n++ } END { if (n > 0) print sum / n; }' $REVIEW_LOG)" 146 | echo -e "" 147 | echo -e "${LGREY}Category:${NC} 148 | ${q[0]}" 149 | echo -e "${LGREY}Question:${NC} 150 | ${q[1]}" 151 | echo -e "" 152 | read -sn 1 NEXT 153 | if [ "$NEXT" = q ] || [ "$NEXT" = Q ]; then 154 | add_usage_entry && cd "$PWD" && exit 155 | fi 156 | echo -e "${LGREY}Answer:${NC} 157 | ${q[2]}" 158 | echo -e "" 159 | echo -e "${WHITEBG}${WHITE}===========================================================${NC}" 160 | echo -e "" 161 | echo -e "${LGREY}How Difficult Was This Question?${NC}" 162 | echo -e "" 163 | echo -e "${LRED}Hard${NC} [1] ${RED}Difficult${NC} [2] ${YELLOW}Normal${NC} [3] ${GREEN}Mild${NC} [4] ${LGREEN}Easy${NC} [5]" 164 | echo -e "" 165 | read -sn 1 DIFFICULTY_SCORE 166 | if [ "$DIFFICULTY_SCORE" = q ] || [ "$DIFFICULTY_SCORE" = Q ]; then 167 | add_usage_entry && cd "$PWD" && exit 168 | fi 169 | clear 170 | 171 | COUNTER="$(($COUNTER+1))" # Increment count for above test and card review count increment 172 | 173 | if [ "${q[3]}" = 0 ]; then 174 | NEW_ITEM_SCORE=0 175 | case "$DIFFICULTY_SCORE" in 176 | [123]) NEW_ITEM_SCORE=0 ;;#HARD DIFFICULTY & NORMAL 177 | 4) NEW_ITEM_SCORE=1 ;;#MILD 178 | 5) NEW_ITEM_SCORE=2 ;;#EASY 179 | *) NEW_ITEM_SCORE=0 ;;#INVALID 180 | esac 181 | 182 | elif [ "${q[3]}" = 1 ]; then 183 | case "$DIFFICULTY_SCORE" in 184 | 1) NEW_ITEM_SCORE=0 ;;#HARD 185 | 2) NEW_ITEM_SCORE=0 ;;#DIFFICULT 186 | 3) NEW_ITEM_SCORE=1 ;;#NORMAL 187 | 4) NEW_ITEM_SCORE=2 ;;#MILD 188 | 5) NEW_ITEM_SCORE=3 ;;#EASY 189 | *) NEW_ITEM_SCORE=1 ;;#INVALID 190 | esac 191 | else 192 | case "$DIFFICULTY_SCORE" in 193 | 1) NEW_ITEM_SCORE="$((${q[3]}-2))" ;;#HARD 194 | 2) NEW_ITEM_SCORE="$((${q[3]}-1))" ;;#DIFFICULTY 195 | 3) NEW_ITEM_SCORE="${q[3]}" ;;#NORMAL 196 | 4) NEW_ITEM_SCORE="$((${q[3]}+1))" ;;#MILD 197 | 5) NEW_ITEM_SCORE="$((${q[3]}+2))" ;;#EASY 198 | *) NEW_ITEM_SCORE="${q[3]}" ;;#INVALID 199 | esac 200 | fi 201 | 202 | # Update item score for each flashcard item 203 | sed -i "s/${q[0]}:${q[1]}:${q[2]}:${q[3]}/${q[0]}:${q[1]}:${q[2]}:$NEW_ITEM_SCORE/g" "$DECK" 204 | # Update highscore if new highscore is achieved 205 | if [ -z "$(cat $HIGH_SCORE)" ]; then 206 | echo "$COUNTER" > "$HIGH_SCORE" 207 | fi 208 | 209 | # If Cards Reviewed > Current High Score, Update 210 | if [ "$COUNTER" -gt "$(cat $HIGH_SCORE)" ]; then 211 | echo "$COUNTER" > "$HIGH_SCORE" 212 | fi 213 | 214 | } 215 | 216 | add_usage_entry(){ 217 | if [ ! "$COUNTER" = 0 ]; then 218 | # Create a New Entry 219 | TIME_STAMP="$(date --rfc-3339=seconds)" 220 | REVIEWED_DECK="$(echo $EXAMPLE_DECK | awk -F/ '{print $7}')" 221 | printf -v ENTRY "TimeStamp: %s Deck: %s cardsReviewed: %s" "$TIME_STAMP" "$REVIEWED_DECK" "$COUNTER" 222 | echo "$ENTRY" >> "$REVIEW_LOG" 223 | fi 224 | } 225 | 226 | while true; do 227 | main 228 | done 229 | -------------------------------------------------------------------------------- /gem: -------------------------------------------------------------------------------- 1 | alias gemb="gem build *.gemspec" 2 | alias gemp="gem push *.gem" 3 | 4 | # gemy GEM 0.0.0 = gem yank GEM -v 0.0.0 5 | function gemy { 6 | gem yank $1 -v $2 7 | } 8 | -------------------------------------------------------------------------------- /i3/i3battery: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Copyright 2014 Pierre Mavro 4 | # Copyright 2014 Vivien Didelot 5 | # 6 | # Licensed under the terms of the GNU GPL v3, or any later version. 7 | # 8 | # This script is meant to use with i3blocks. It parses the output of the "acpi" 9 | # command (often provided by a package of the same name) to read the status of 10 | # the battery, and eventually its remaining time (to full charge or discharge). 11 | # 12 | # The color will gradually change for a percentage below 85%, and the urgency 13 | # (exit code 33) is set if there is less that 5% remaining. 14 | 15 | use strict; 16 | use warnings; 17 | use utf8; 18 | 19 | my $acpi; 20 | my $status; 21 | my $percent; 22 | my $ac_adapt; 23 | my $full_text; 24 | my $short_text; 25 | my $bat_number = $ENV{BAT_NUMBER} || 0; 26 | my $label = $ENV{LABEL} || ""; 27 | 28 | # read the first line of the "acpi" command output 29 | open (ACPI, "acpi -b 2>/dev/null| grep 'Battery $bat_number' |") or die; 30 | $acpi = ; 31 | close(ACPI); 32 | 33 | # fail on unexpected output 34 | if (not defined($acpi)) { 35 | # don't print anything to stderr if there is no battery 36 | exit(0); 37 | } 38 | elsif ($acpi !~ /: ([\w\s]+), (\d+)%/) { 39 | die "$acpi\n"; 40 | } 41 | 42 | $status = $1; 43 | $percent = $2; 44 | $full_text = ""; 45 | 46 | if ($status eq 'Discharging') { 47 | $full_text .= '⚡ '; 48 | } elsif ($status eq 'Charging') { 49 | $full_text .= '🔌 '; 50 | } elsif ($status eq 'Unknown') { 51 | open (AC_ADAPTER, "acpi -a |") or die; 52 | $ac_adapt = ; 53 | close(AC_ADAPTER); 54 | 55 | if ($ac_adapt =~ /: ([\w-]+)/) { 56 | $ac_adapt = $1; 57 | 58 | if ($ac_adapt eq 'on-line') { 59 | $full_text .= '🔌 '; 60 | } elsif ($ac_adapt eq 'off-line') { 61 | $full_text .= '⚡ '; 62 | } 63 | } 64 | } else { 65 | $full_text .= '🔋 ' 66 | } 67 | 68 | $full_text .= "$percent%"; 69 | 70 | if ($acpi =~ /(\d\d:\d\d):/) { 71 | $full_text .= " ($1)"; 72 | } 73 | 74 | # print text 75 | print "$full_text\n"; 76 | 77 | # consider color and urgent flag only on discharge 78 | if ($status eq 'Discharging') { 79 | 80 | if ($percent < 20) { 81 | print "#FF0000\n"; 82 | } elsif ($percent < 40) { 83 | print "#FFAE00\n"; 84 | } elsif ($percent < 60) { 85 | print "#FFF600\n"; 86 | } elsif ($percent < 85) { 87 | print "#A8FF00\n"; 88 | } 89 | 90 | if ($percent < 5) { 91 | exit(33); 92 | } 93 | } 94 | 95 | exit(0); 96 | -------------------------------------------------------------------------------- /i3/i3cpu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Copyright 2014 Pierre Mavro 4 | # Copyright 2014 Vivien Didelot 5 | # Copyright 2014 Andreas Guldstrand 6 | # 7 | # Licensed under the terms of the GNU GPL v3, or any later version. 8 | 9 | use strict; 10 | use warnings; 11 | use utf8; 12 | use Getopt::Long; 13 | 14 | # default values 15 | my $t_warn = $ENV{T_WARN} // 50; 16 | my $t_crit = $ENV{T_CRIT} // 80; 17 | my $cpu_usage = -1; 18 | my $decimals = $ENV{DECIMALS} // 2; 19 | my $label = $ENV{LABEL} // ""; 20 | 21 | sub help { 22 | print "Usage: cpu_usage [-w ] [-c ] [-d ]\n"; 23 | print "-w : warning threshold to become yellow\n"; 24 | print "-c : critical threshold to become red\n"; 25 | print "-d : Use decimals for percentage (default is $decimals) \n"; 26 | exit 0; 27 | } 28 | 29 | GetOptions("help|h" => \&help, 30 | "w=i" => \$t_warn, 31 | "c=i" => \$t_crit, 32 | "d=i" => \$decimals, 33 | ); 34 | 35 | # Get CPU usage 36 | $ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is 37 | open (MPSTAT, 'mpstat 1 1 |') or die; 38 | while () { 39 | if (/^.*\s+(\d+\.\d+)[\s\x00]?$/) { 40 | $cpu_usage = 100 - $1; # 100% - %idle 41 | last; 42 | } 43 | } 44 | close(MPSTAT); 45 | 46 | $cpu_usage eq -1 and die 'Can\'t find CPU information'; 47 | 48 | # Print short_text, full_text 49 | print "${label}"; 50 | printf "%.${decimals}f%%\n", $cpu_usage; 51 | printf "\n"; 52 | 53 | 54 | # Print color, if needed 55 | if ($cpu_usage >= $t_crit) { 56 | print "#FF0000\n"; 57 | exit 33; 58 | } elsif ($cpu_usage >= $t_warn) { 59 | print "#FFFC00\n"; 60 | } 61 | 62 | exit 0; 63 | -------------------------------------------------------------------------------- /i3/i3disk: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (C) 2014 Julien Bonjean 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | DIR="${DIR:-$BLOCK_INSTANCE}" 18 | DIR="${DIR:-$HOME}" 19 | ALERT_LOW="${ALERT_LOW:-$1}" 20 | ALERT_LOW="${ALERT_LOW:-10}" # color will turn red under this value (default: 10%) 21 | 22 | LOCAL_FLAG="-l" 23 | if [ "$1" = "-n" ] || [ "$2" = "-n" ]; then 24 | LOCAL_FLAG="" 25 | fi 26 | 27 | df -h -P $LOCAL_FLAG "$DIR" | awk -v label="$LABEL" -v alert_low=$ALERT_LOW ' 28 | /\/.*/ { 29 | # full text 30 | print label $4 31 | # short text 32 | print label $4 33 | use=$5 34 | # no need to continue parsing 35 | exit 0 36 | } 37 | END { 38 | gsub(/%$/,"",use) 39 | if (100 - use < alert_low) { 40 | # color 41 | print "#FF0000" 42 | } 43 | } 44 | ' 45 | -------------------------------------------------------------------------------- /i3/i3ip: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/bash 3 | # Copyright (C) 2014 Julien Bonjean 4 | # Copyright (C) 2014 Alexander Keller 5 | 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | #------------------------------------------------------------------------ 20 | 21 | # Use the provided interface, otherwise the device used for the default route. 22 | IF="${IFACE:-$BLOCK_INSTANCE}" 23 | IF="${IF:-$(ip route | awk '/^default/ { print $5 ; exit }')}" 24 | 25 | # Exit if there is no default route 26 | [[ -z "$IF" ]] && exit 27 | 28 | #------------------------------------------------------------------------ 29 | 30 | # As per #36 -- It is transparent: e.g. if the machine has no battery or wireless 31 | # connection (think desktop), the corresponding block should not be displayed. 32 | [[ ! -d /sys/class/net/${IF} ]] && exit 33 | 34 | #------------------------------------------------------------------------ 35 | 36 | AF=${ADDRESS_FAMILY:-inet6?} 37 | LABEL="${LABEL:-}" 38 | 39 | for flag in "$1" "$2"; do 40 | case "$flag" in 41 | -4) 42 | AF=inet ;; 43 | -6) 44 | AF=inet6 ;; 45 | -L) 46 | if [[ "$IF" = "" ]]; then 47 | LABEL="iface " 48 | else 49 | LABEL="$IF: " 50 | fi ;; 51 | esac 52 | done 53 | 54 | if [[ "$IF" = "" ]] || [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then 55 | echo "${LABEL}down" # full text 56 | echo "${LABEL}down" # short text 57 | echo \#FF0000 # color 58 | exit 59 | fi 60 | 61 | # if no interface is found, use the first device with a global scope 62 | IPADDR=$(ip addr show $IF | perl -n -e "/$AF ([^ \/]+).* scope global/ && print \$1 and exit") 63 | 64 | case $BLOCK_BUTTON in 65 | 3) echo -n "$IPADDR" | xclip -q -se c ;; 66 | esac 67 | 68 | #------------------------------------------------------------------------ 69 | 70 | echo "$LABEL$IPADDR" # full text 71 | -------------------------------------------------------------------------------- /i3/i3memory: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (C) 2014 Julien Bonjean 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | TYPE="${BLOCK_INSTANCE:-mem}" 18 | 19 | awk -v type=$TYPE ' 20 | /^MemTotal:/ { 21 | mem_total=$2 22 | } 23 | /^MemFree:/ { 24 | mem_free=$2 25 | } 26 | /^Buffers:/ { 27 | mem_free+=$2 28 | } 29 | /^Cached:/ { 30 | mem_free+=$2 31 | } 32 | /^SwapTotal:/ { 33 | swap_total=$2 34 | } 35 | /^SwapFree:/ { 36 | swap_free=$2 37 | } 38 | END { 39 | if (type == "swap") { 40 | free=swap_free/1024/1024 41 | used=(swap_total-swap_free)/1024/1024 42 | total=swap_total/1024/1024 43 | } else { 44 | free=mem_free/1024/1024 45 | used=(mem_total-mem_free)/1024/1024 46 | total=mem_total/1024/1024 47 | } 48 | pct=0 49 | if (total > 0) { 50 | pct=used/total*100 51 | } 52 | # full text 53 | printf("%.1fG/%.1fG", used, total) 54 | } 55 | ' /proc/meminfo 56 | -------------------------------------------------------------------------------- /i3/i3speedtest: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # i3block for displaying the current network speed 3 | speedtest-cli | grep -E "Download|Upload" | awk '{print $2}' | tr '\n' ' ' | awk '{print "📥 " $1 " " "📤 " $2}' 4 | -------------------------------------------------------------------------------- /i3/i3temp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple script to show the CPU temperature formatted for use with i3blocks 3 | temp=$(acpi -t | sed 's/.*, //;s/ degrees //;s/C//') 4 | echo $temp°C 5 | echo $temp°C 6 | 7 | if [ 1 -eq "$(echo "$temp > 85" | bc)" ]; then 8 | echo "#FFAE00" 9 | elif [ 1 -eq "$(echo "$temp > 65" | bc)" ]; then 10 | echo "#FFF600" 11 | fi 12 | -------------------------------------------------------------------------------- /i3/i3torrents: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # i3block for displaying the number of torrents that are currently downloading, paused and being seeded 3 | 4 | torrents=$(transmission-remote -l) 5 | downloading=$(echo "$torrents" | grep "Downloading\|Up & Down" | wc -l) 6 | paused=$(echo "$torrents" | grep "Stopped" | wc -l) 7 | seeding=$(echo "$torrents" | grep "Seeding" | wc -l) 8 | idle=$(echo "$torrents" | grep "Idle" | wc -l) 9 | 10 | echo "📥 $downloading 🛑 $paused 📤 $seeding 🗄️ $idle" 11 | -------------------------------------------------------------------------------- /i3/i3volume: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # i3block for displaying the current master and headphone volume 3 | 4 | master=$(amixer get Master | grep Mono: | awk '{print $4 " " $6}' | sed 's/\[//g;s/\]//g') 5 | headphone=$(amixer get Headphone | grep Right: | awk '{print $5 " " $7}' | sed 's/\[//g;s/\]//g') 6 | speaker=$(amixer get Speaker | grep Right: | awk '{print $5 " " $7}' | sed 's/\[//g;s/\]//g') 7 | echo $speaker 8 | 9 | printf "🔊 " 10 | 11 | if [ "$(echo $master | awk '{print $2}')" == "on" ]; then 12 | echo -n "$(echo $master | awk '{print $1}')" 13 | else 14 | echo -n "mute" 15 | fi 16 | 17 | printf " 🎧 " 18 | 19 | if [ "$(echo $headphone | awk '{print $2}')" == "on" ]; then 20 | echo -n "$(echo $headphone | awk '{print $1}')" 21 | else 22 | echo -n "mute" 23 | fi 24 | 25 | printf " 📻 " 26 | 27 | if [ "$(echo $speaker | awk '{print $2}')" == "on" ]; then 28 | echo -n "$(echo $speaker | awk '{print $1}')" 29 | else 30 | echo -n "mute" 31 | fi 32 | 33 | printf "\n" 34 | -------------------------------------------------------------------------------- /i3/i3weather: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # i3block for displaying the current temperature, humidity and precipitation, if wttr.in i unavailable then WEATHER UNAVAILABLE will be displayed 3 | 4 | weather=$(curl -s wttr.in/Adelaide?format=3) 5 | 6 | if [ $(echo "$weather" | grep -E "(Unknown|curl|HTML)" | wc -l) -gt 0 ]; then 7 | echo "WEATHER UNAVAILABLE" 8 | else 9 | echo "$weather" | awk '{print $2" "$3}' 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /i3/i3wifi: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # i3block for the displaying the wifi connectivity level 3 | # If the wifi interface exists but no connection is active, "down" shall be displayed. 4 | 5 | if [[ "$(cat /sys/class/net/$1/operstate)" = 'down' ]]; then 6 | echo "down" 7 | echo "down" 8 | echo "#FF0000" 9 | exit 10 | fi 11 | 12 | QUALITY=$(grep $1 /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') 13 | 14 | echo $QUALITY% # full text 15 | 16 | # color 17 | if [[ $QUALITY -ge 80 ]]; then 18 | echo "#00FF00" 19 | elif [[ $QUALITY -ge 60 ]]; then 20 | echo "#FFF600" 21 | elif [[ $QUALITY -ge 40 ]]; then 22 | echo "#FFAE00" 23 | else 24 | echo "#FF0000" 25 | fi 26 | -------------------------------------------------------------------------------- /inf: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | id=$(xdo id) 3 | echo $id > .cache/cam_indicator 4 | bspc node -g sticky -t floating 5 | 6 | while true; 7 | do sleep 1; 8 | done 9 | -------------------------------------------------------------------------------- /joshuto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrodieRobertson/scripts/ae0077d38777151e07824410fade622eb93f0ca0/joshuto -------------------------------------------------------------------------------- /kdenchapters: -------------------------------------------------------------------------------- 1 | /home/brodie/repos/kdenchapters/kdenchapters -------------------------------------------------------------------------------- /killandnotify: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Kills an application and sends a notification that it's been killed 3 | 4 | killall $1 && notify-send "$1" "$2" 5 | -------------------------------------------------------------------------------- /launchspt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! $(pgrep "spotifyd") ]; then 4 | spotifyd 5 | fi 6 | 7 | spt 8 | -------------------------------------------------------------------------------- /lemonbar/launchlemon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Launches an instance of lemonbar 3 | killall -q lemonbar 4 | killall -q lemonconfig 5 | 6 | lemonconfig | lemonbar -p -g 1920x32+0+0 -F "#FFFFFFFF" -B "#FF222222" -U "#268bd2" -u 3 -o -4 -f "JetBrains Mono Medium"-14 -o -2 -f "Hack Nerd Font"-18 | $SHELL 7 | 8 | -------------------------------------------------------------------------------- /lemonbar/lemonconfig: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # Outputs a configuration for lemonbar 3 | 4 | trap 'Update' 5 5 | 6 | background="#2D2D2D" 7 | 8 | Format() { 9 | echo "%{+u}%{B$background} $1 %{B}%{-u}" 10 | } 11 | 12 | Workspaces() { 13 | desktops=$(bspc query -D --names) 14 | focused=$(bspc query -D --names -d focused) 15 | 16 | for desktop in $desktops; do 17 | desktop=$(echo "$desktop") 18 | nodes=$(bspc query -N -d $desktop) 19 | 20 | if [ ! -z "$nodes" ]; then 21 | desktops=$(echo $desktops | sed "s/$desktop/%{F#ff0000}$desktop%{F-}/") 22 | fi 23 | 24 | done 25 | desktops=$(echo $desktops | sed "s/$focused/%{B$background}%{+u}_$focused\_%{-u}%{B-}/") 26 | 27 | echo $desktops | sed "s/_/ /g" 28 | } 29 | 30 | CpuTemp() { 31 | temp=$(sensors | grep "Tdie" | sed "s/Tdie: *+//;s/°C *//") 32 | if [ 1 -eq "$(echo "$temp > 80" | bc)" ]; then 33 | printf "%%{F#ed0b0b}" 34 | elif [ 1 -eq "$(echo "$temp > 60" | bc)" ]; then 35 | printf "%%{F#f2e421}"; 36 | fi 37 | Format ""$temp"°C%{F-}" 38 | } 39 | 40 | Cpu() { 41 | usage=$(mpstat | sed '1,3d;s/.* //') 42 | output="$(calc 100 - $usage)" 43 | Format "$output" 44 | } 45 | 46 | Clock(){ 47 | DATE=$(date "+%d/%m/%y") 48 | TIME=$(date "+%I:%M:%S") 49 | 50 | Format "${DATE} ${TIME}" 51 | } 52 | 53 | ActiveWindow(){ 54 | printf " $(xdotool getwindowfocus getwindowname)" 55 | } 56 | 57 | Packages() { 58 | Format "$(sudo pacman -Qu | wc -l)" 59 | } 60 | 61 | Subs() { 62 | #Format "$(polysubs)" 63 | Format "7.42k 116" 64 | } 65 | 66 | 67 | Memory() { 68 | echo "%{A:$TERMINAL -e htop:}$(Format "$(i3memory)")%{A}" 69 | } 70 | 71 | Sound(){ 72 | device=$(pulsedevices | grep "pci-0000_0b" -A 2) 73 | mute=$(echo "$device" | grep "Mute" | awk '{ print $2 }') 74 | vol=$(echo "$device" | grep "front-left" | awk '{ print $5 }') 75 | output="" 76 | 77 | if [ "$mute" = "yes" ]; then 78 | output="🔇 mute" 79 | elif [ "$(echo "$vol" | tr -d "%")" -gt 70 ]; then 80 | output="🔊 $vol" 81 | elif [ "$(echo "$vol" | tr -d "%")" -gt 35 ]; then 82 | output="奔 $vol" 83 | else 84 | output="🔈 $vol" 85 | fi 86 | 87 | Format "$output" 88 | } 89 | 90 | Weather() { 91 | Format $(cat ~/.cache/weather) 92 | } 93 | 94 | NewModule() { 95 | echo "%{B#aef4e3}%{+u}Hello World%{-u}%{B}" 96 | } 97 | 98 | Update() { 99 | echo -e "%{l}$(Workspaces) $(ActiveWindow) %{r} $(Packages) $(Subs) $(Cpu) $(CpuTemp) $(Memory) $(Sound) $(Weather) $(Clock)" 100 | #echo -e "%{r} $(NewModule)" 101 | } 102 | 103 | while true; do 104 | Update 105 | sleep 5s & 106 | wait 107 | done 108 | -------------------------------------------------------------------------------- /lemonbar/lemoncpu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | usage=$(mpstat 1 1 | sed '1,4d;s/.* //') 3 | output="$(calc 100 - $usage)" 4 | 5 | echo "$output" 6 | -------------------------------------------------------------------------------- /lemonbar/lemoncputemp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "$(sensors | grep "Tdie" | sed "s/Tdie: *+//;s/°C *//")°C" 3 | -------------------------------------------------------------------------------- /lemonbar/lemonpackages: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sudo pacman -Qu | wc -l 3 | -------------------------------------------------------------------------------- /lemonbar/lemontime: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DATE=$(date "+%d/%m/%y") 4 | TIME=$(date "+%I:%M:%S") 5 | 6 | echo "${DATE} ${TIME}" 7 | -------------------------------------------------------------------------------- /lemonworkspaces: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | desktops=$(bspc query -D --names) 4 | focused=$(bspc query -D --names -d focused) 5 | 6 | for desktop in $desktops; do 7 | desktop=$(echo "$desktop") 8 | nodes=$(bspc query -N -d $desktop) 9 | 10 | if [ ! -z "$nodes" ]; then 11 | desktops=$(echo $desktops | sed "s/$desktop/%{F#ff0000}$desktop%{F-}/") 12 | fi 13 | 14 | done 15 | desktops=$(echo $desktops | sed "s/$focused/%{B#444444}%{+u}_$focused\_%{-u}%{B-}/") 16 | 17 | 18 | echo $desktops | sed "s/_/ /g" 19 | -------------------------------------------------------------------------------- /lf/preview: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Preview script built for use with lf and fzf 3 | 4 | handle() { 5 | if [ -f "$1" ]; 6 | then 7 | highlight "$1" -O ansi --force 8 | elif [ -d "$1" ]; 9 | then 10 | tree "$1" -La 1 11 | fi 12 | } 13 | 14 | case "$1" in 15 | *.png|*.jpg|*.jpeg|*.mkv|*.mp4|*.m4v) mediainfo "$1";; 16 | *.md) glow -s dark "$1";; 17 | *.pdf) pdftotext "$1" -;; 18 | *.zip) zipinfo "$1";; 19 | *.tar.gz) tar -ztvf "$1";; 20 | *.tar.bz2) tar -jtvf "$1";; 21 | *.tar) tar -tvf "$1";; 22 | *.rar) unrar l "$1";; 23 | *.7z) 7z l "$1";; 24 | #*.html|*.xml) w3m -dump "$1";; 25 | *.zsh*|*.bash*|*.git*) pistol "$1";; 26 | *) handle "$1" ;; 27 | esac 28 | 29 | -------------------------------------------------------------------------------- /luc: -------------------------------------------------------------------------------- 1 | /home/brodie/repos/lbryurlconvert/lbryurlconvert -------------------------------------------------------------------------------- /mepapemaker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | pape=$1 4 | 5 | # Get the width of the wallpaper 6 | height=$(magick convert "$pape" -format "%h" info:) 7 | width=$(magick convert "$pape" -format "%w" info:) 8 | 9 | # Calculate appropriate height for logo on the wallpaper 10 | logo_height=$(($height*9/16)) 11 | 12 | # Generate Mask 13 | convert "./arch.png" -gravity center -resize $logo_height -background white -extent "${width}x${height}" -flatten "temp_logo.png" 14 | 15 | # Generate Wallpaper 16 | outfile_name=$(basename "$pape") 17 | 18 | convert "$pape" -write-mask "temp_logo.png" -gravity center \ 19 | -blur 0x30 \ 20 | -attenuate 0.3 +noise Laplacian\ 21 | -evaluate Multiply 1.3 \ 22 | "arch_btw_$outfile_name" 23 | 24 | # Delete temporary file 25 | rm "temp_logo.png" 26 | 27 | # TODO: imagemagick giving colorspace warning 28 | # TODO: Use SVG instead of png? 29 | -------------------------------------------------------------------------------- /mkscript: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple script to generate a script file in my scripts directory 3 | 4 | printf "File Name: " 5 | 6 | # Set a name for the script 7 | while [ -z "$ans" ]; 8 | do 9 | read -r ans 10 | 11 | if [ -z "$ans" ]; then 12 | printf "File Name: " 13 | fi 14 | done 15 | 16 | file=$HOME/scripts/$ans 17 | 18 | if [ -d "$HOME/scripts" ]; then 19 | if [ -e "$HOME/scripts/$ans" ]; then 20 | $EDITOR "$file" 21 | else 22 | echo "#!/bin/sh" >> "$file" 23 | chmod +x "$file" 24 | $EDITOR "$file" 25 | fi 26 | fi 27 | -------------------------------------------------------------------------------- /mousemove: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | Amount=10 4 | 5 | HandleClick() { 6 | if [ "$ClickType" = "up" ]; then 7 | case "$Click" in 8 | "1") xdotool mouseup 1 ;; 9 | "2") xdotool mouseup 2 ;; 10 | "3") xdotool mouseup 3 ;; 11 | "4") xdotool mouseup 4 ;; 12 | "5") xdotool mouseup 5 ;; 13 | esac 14 | elif [ "$ClickType" = "down" ]; then 15 | case "$Click" in 16 | "1") xdotool mousedown 1 ;; 17 | "2") xdotool mousedown 2 ;; 18 | "3") xdotool mousedown 3 ;; 19 | "4") xdotool mousedown 4 ;; 20 | "5") xdotool mousedown 5 ;; 21 | esac 22 | else 23 | case "$Click" in 24 | "1") xdotool click 1 ;; 25 | "2") xdotool click 2 ;; 26 | "3") xdotool click 3 ;; 27 | "4") xdotool click 4 ;; 28 | "5") xdotool click 5 ;; 29 | esac 30 | fi 31 | 32 | } 33 | 34 | HandleMove() { 35 | case "$Direction" in 36 | "left") xdotool mousemove_relative -- -$Amount 0 ;; 37 | "right") xdotool mousemove_relative $Amount 0 ;; 38 | "up") xdotool mousemove_relative -- 0 -$Amount ;; 39 | "down") xdotool mousemove_relative 0 $Amount ;; 40 | "up-left") xdotool mousemove_relative -- -$Amount -$Amount ;; 41 | "up-right") xdotool mousemove_relative -- $Amount -$Amount ;; 42 | "down-left") xdotool mousemove_relative -- -$Amount $Amount;; 43 | "down-right") xdotool mousemove_relative $Amount $Amount;; 44 | esac 45 | } 46 | 47 | # Loop over arguments to script 48 | for Value in "$@" 49 | do 50 | # Handle options 51 | case "$Value" in 52 | # Options requring arguments 53 | -a|-m|-c|-u|-d) OptionSet=$Value ;; 54 | -h|--help) HelpPage; exit 0;; 55 | esac 56 | 57 | # Handle arguments 58 | if [ -n "$OptionSet" ]; then 59 | case "$OptionSet" in 60 | -a) Amount=$Value ;; 61 | -m) Direction=$Value ;; 62 | -u|-d) ClickType=$Value;; 63 | -c) Click=$Value ;; 64 | *) Err 1 "Invalid option set" ;; 65 | esac 66 | fi 67 | done 68 | 69 | if [ -n "$Direction" ]; then 70 | HandleMove 71 | fi 72 | 73 | if [ -n "$Click" ]; then 74 | HandleClick 75 | fi 76 | -------------------------------------------------------------------------------- /mp3convert: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for i in "$1"/* 3 | do 4 | ffmpeg -i "$i" -f mp3 "$2/$(basename "$i").mp3" && rm "$i" 5 | rm "$i" 6 | done 7 | -------------------------------------------------------------------------------- /multimonitor: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Wrapper script for extramonitor 3 | printf "disconnect\nextra\nduplicate" | dmenu -i -p "Monitor Configuration" | xargs -I % extramonitor "%" "$1" "$2" 4 | -------------------------------------------------------------------------------- /nodechildren: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Gets the children of a window 3 | 4 | id=$1 5 | xwininfo -id "$id" -children | sed -n '/[0-9]\+ \(child\|children\):/,$s/ \+\(0x[0-9a-z]\+\).*/\1/p' 6 | -------------------------------------------------------------------------------- /nodeclass: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Gets the window class of a window 3 | 4 | id=$1 5 | if [ -z "$id" ]; then 6 | echo "" 7 | else 8 | xprop -id "$id" | sed -n '/WM_CLASS/s/.*, "\(.*\)"/\1/p' 9 | fi 10 | -------------------------------------------------------------------------------- /nodename: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Gets the window class of a window 3 | 4 | id=$1 5 | if [ -z "$id" ]; then 6 | echo "" 7 | else 8 | xprop -id "$id" | grep ^WM_NAME\(UTF8_STRING\) | awk '{print $3}' | tr -d '"' 9 | fi 10 | -------------------------------------------------------------------------------- /notifycrypto: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | Output= 3 | for file in ~/.cache/crypto/* 4 | do 5 | if [ ! -z "$Output" ]; then 6 | if [ ! $(basename $file) = "time" ]; then 7 | Output="$Output\n$(cat $file)" 8 | fi 9 | else 10 | if [ ! $(basename $file) = "time" ]; then 11 | Output="$Output$(cat $file)" 12 | fi 13 | fi 14 | 15 | done 16 | 17 | Output="$Output\n$(cat ~/.cache/crypto/time)" 18 | notify-send "Crypto Prices" "$Output" 19 | -------------------------------------------------------------------------------- /opnbrow: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Handler script for opening a link in a browser 3 | 4 | handle_default() { 5 | if [ ! -z "$1" ]; then 6 | $1 "$2" 7 | elif [ ! -z "$BROWSER" ]; then 8 | $BROWSER $2 9 | fi 10 | } 11 | 12 | if [ "$2" ]; then 13 | # Special handling for browsers that support tabbing 14 | case "$1" in 15 | "firefox") firefox --new-tab "$2" ;; 16 | *) handle_default ;; 17 | esac 18 | fi 19 | -------------------------------------------------------------------------------- /opout: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # opout: "open output": A general handler for opening a file's intended output. 3 | # I find this useful especially running from vim. 4 | 5 | basename="$(echo "$1" | sed 's/\.[^\/.]*$//')" 6 | 7 | case "$1" in 8 | *.tex|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$READER" "$basename".pdf >/dev/null 2>&1 & ;; 9 | *.html) setsid "$BROWSER" --new-window "$basename".html >/dev/null 2>&1 & ;; 10 | esac 11 | -------------------------------------------------------------------------------- /pfetch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # pfetch - Simple POSIX sh fetch script. 4 | 5 | log() { 6 | # The 'log()' function handles the printing of information. 7 | # In 'pfetch' (and 'neofetch'!) the printing of the ascii art and info 8 | # happen independently of each other. 9 | # 10 | # The size of the ascii art is stored and the ascii is printed first. 11 | # Once the ascii is printed, the cursor is located right below the art 12 | # (See marker $[1]). 13 | # 14 | # Using the stored ascii size, the cursor is then moved to marker $[2]. 15 | # This is simply a cursor up escape sequence using the "height" of the 16 | # ascii art. 17 | # 18 | # 'log()' then moves the cursor to the right the "width" of the ascii art 19 | # with an additional amount of padding to add a gap between the art and 20 | # the information (See marker $[3]). 21 | # 22 | # When 'log()' has executed, the cursor is then located at marker $[4]. 23 | # When 'log()' is run a second time, the next line of information is 24 | # printed, moving the cursor to marker $[5]. 25 | # 26 | # Markers $[4] and $[5] repeat all the way down through the ascii art 27 | # until there is no more information left to print. 28 | # 29 | # Every time 'log()' is called the script keeps track of how many lines 30 | # were printed. When printing is complete the cursor is then manually 31 | # placed below the information and the art according to the "heights" 32 | # of both. 33 | # 34 | # The math is simple: move cursor down $((ascii_height - info_height)). 35 | # If the aim is to move the cursor from marker $[5] to marker $[6], 36 | # plus the ascii height is 8 while the info height is 2 it'd be a move 37 | # of 6 lines downwards. 38 | # 39 | # However, if the information printed is "taller" (takes up more lines) 40 | # than the ascii art, the cursor isn't moved at all! 41 | # 42 | # Once the cursor is at marker $[6], the script exits. This is the gist 43 | # of how this "dynamic" printing and layout works. 44 | # 45 | # This method allows ascii art to be stored without markers for info 46 | # and it allows for easy swapping of info order and amount. 47 | # 48 | # $[2] ___ $[3] goldie@KISS 49 | # $[4](.· | $[5] os KISS Linux 50 | # (<> | 51 | # / __ \ 52 | # ( / \ /| 53 | # _/\ __)/_) 54 | # \/-____\/ 55 | # $[1] 56 | # 57 | # $[6] /home/goldie $ 58 | 59 | # End here if no data was found. 60 | [ "$2" ] || return 61 | 62 | # Store the value of '$1' as we reset the argument list below. 63 | name=$1 64 | 65 | # Use 'set --' as a means of stripping all leading and trailing 66 | # white-space from the info string. This also normalizes all 67 | # white-space inside of the string. 68 | # 69 | # Disable the shellcheck warning for word-splitting 70 | # as it's safe and intended ('set -f' disables globbing). 71 | # shellcheck disable=2046,2086 72 | { 73 | set -f 74 | set +f -- $2 75 | info=$* 76 | } 77 | 78 | # Move the cursor to the right, the width of the ascii art with an 79 | # additional gap for text spacing. 80 | printf '[%sC' "${ascii_width--1}" 81 | 82 | # Print the info name and color the text. 83 | printf '[3%s;1m%s' "${PF_COL1-4}" "$name" 84 | 85 | # Print the info name and info data separator. 86 | printf '%s' "$PF_SEP" 87 | 88 | # Move the cursor backward the length of the *current* info name and 89 | # then move it forwards the length of the *longest* info name. This 90 | # aligns each info data line. 91 | printf '[%sD[%sC' "${#name}" "${PF_ALIGN-$info_length}" 92 | 93 | # Print the info data, color it and strip all leading whitespace 94 | # from the string. 95 | printf '[3%sm%s\n' "${PF_COL2-7}" "$info" 96 | 97 | # Keep track of the number of times 'log()' has been run. 98 | info_height=$((${info_height:-0} + 1)) 99 | } 100 | 101 | get_title() { 102 | # Username is retrieved by first checking '$USER' with a fallback 103 | # to the 'id -un' command. 104 | user=${USER:-$(id -un)} 105 | 106 | # Hostname is retrieved by first checking '$HOSTNAME' with a fallback 107 | # to the 'hostname' command. 108 | # 109 | # Disable the warning about '$HOSTNAME' being undefined in POSIX sh as 110 | # the intention for using it is allowing the user to overwrite the 111 | # value on invocation. 112 | # shellcheck disable=SC2039 113 | hostname=${HOSTNAME:-${hostname:-$(hostname)}} 114 | 115 | log "[3${PF_COL3:-1}m${user}${c7}@[3${PF_COL3:-1}m${hostname}" " " >&6 116 | } 117 | 118 | get_os() { 119 | # This function is called twice, once to detect the distribution name 120 | # for the purposes of picking an ascii art early and secondly to display 121 | # the distribution name in the info output (if enabled). 122 | # 123 | # On first run, this function displays _nothing_, only on the second 124 | # invocation is 'log()' called. 125 | [ "$distro" ] && { 126 | log os "$distro" >&6 127 | return 128 | } 129 | 130 | case $os in 131 | Linux*) 132 | # Some Linux distributions (which are based on others) 133 | # fail to identify as they **do not** change the upstream 134 | # distributions identification packages or files. 135 | # 136 | # It is senseless to add a special case in the code for 137 | # each and every distribution (which _is_ technically no 138 | # different from what it is based on) as they're either too 139 | # lazy to modify upstream's identification files or they 140 | # don't have the know-how (or means) to ship their own 141 | # lsb-release package. 142 | # 143 | # This causes users to think there's a bug in system detection 144 | # tools like neofetch or pfetch when they technically *do* 145 | # function correctly. 146 | # 147 | # Exceptions are made for distributions which are independent, 148 | # not based on another distribution or follow different 149 | # standards. 150 | # 151 | # This applies only to distributions which follow the standard 152 | # by shipping unmodified identification files and packages 153 | # from their respective upstreams. 154 | if command -v lsb_release; then 155 | distro=$(lsb_release -sd) 156 | 157 | # Android detection works by checking for the existence of 158 | # the follow two directories. I don't think there's a simpler 159 | # method than this. 160 | elif [ -d /system/app ] && [ -d /system/priv-app ]; then 161 | distro="Android $(getprop ro.build.version.release)" 162 | 163 | else 164 | # This used to be a simple '. /etc/os-release' but I believe 165 | # this is insecure as we blindly executed whatever was in the 166 | # file. This parser instead simply handles 'key=val', treating 167 | # the file contents as plain-text. 168 | while IFS='=' read -r key val; do 169 | case $key in 170 | PRETTY_NAME) distro=$val ;; 171 | esac 172 | done < /etc/os-release 173 | fi 174 | 175 | # 'os-release' and 'lsb_release' sometimes add quotes 176 | # around the distribution name, strip them. 177 | distro=${distro##[\"\']} 178 | distro=${distro%%[\"\']} 179 | 180 | # Special cases for (independent) distributions which 181 | # don't follow any os-release/lsb standards whatsoever. 182 | command -v crux && distro=$(crux) 183 | command -v guix && distro='Guix System' 184 | 185 | # Check to see if Linux is running in Windows 10 under 186 | # WSL1 (Windows subsystem for Linux [version 1]) and 187 | # append a string accordingly. 188 | # 189 | # If the kernel version string ends in "-Microsoft", 190 | # we're very likely running under Windows 10 in WSL1. 191 | [ "${kernel%%*-Microsoft}" ] || 192 | distro="$distro on Windows 10 [WSL1]" 193 | 194 | # Check to see if Linux is running in Windows 10 under 195 | # WSL2 (Windows subsystem for Linux [version 2]) and 196 | # append a string accordingly. 197 | # 198 | # This checks to see if '$WSLENV' is defined. This 199 | # appends the Windows 10 string even if '$WSLENV' is 200 | # empty. We only need to check that is has been _exported_. 201 | distro="${distro}${WSLENV+ on Windows 10 [WSL2]}" 202 | ;; 203 | 204 | Darwin*) 205 | # Parse the SystemVersion.plist file to grab the macOS 206 | # version. The file is in the following format: 207 | # 208 | # ProductVersion 209 | # 10.14.6 210 | # 211 | # 'IFS' is set to '<>' to enable splitting between the 212 | # keys and a second 'read' is used to operate on the 213 | # next line directly after a match. 214 | # 215 | # '_' is used to nullify a field. '_ _ line _' basically 216 | # says "populate $line with the third field's contents". 217 | while IFS='<>' read -r _ _ line _; do 218 | case $line in 219 | # Match 'ProductVersion' and read the next line 220 | # directly as it contains the key's value. 221 | ProductVersion) 222 | IFS='<>' read -r _ _ mac_version _ 223 | break 224 | ;; 225 | esac 226 | done < /System/Library/CoreServices/SystemVersion.plist 227 | 228 | # Use the ProductVersion to determine which macOS/OS X codename 229 | # the system has. As far as I'm aware there's no "dynamic" way 230 | # of grabbing this information. 231 | case $mac_version in 232 | 10.4*) distro='Mac OS X Tiger' ;; 233 | 10.5*) distro='Mac OS X Leopard' ;; 234 | 10.6*) distro='Mac OS X Snow Leopard' ;; 235 | 10.7*) distro='Mac OS X Lion' ;; 236 | 10.8*) distro='OS X Mountain Lion' ;; 237 | 10.9*) distro='OS X Mavericks' ;; 238 | 10.10*) distro='OS X Yosemite' ;; 239 | 10.11*) distro='OS X El Capitan' ;; 240 | 10.12*) distro='macOS Sierra' ;; 241 | 10.13*) distro='macOS High Sierra' ;; 242 | 10.14*) distro='macOS Mojave' ;; 243 | 10.15*) distro='macOS Catalina' ;; 244 | *) distro='macOS' ;; 245 | esac 246 | 247 | distro="$distro $mac_version" 248 | ;; 249 | 250 | Haiku) 251 | # Haiku uses 'uname -v' for version information 252 | # instead of 'uname -r' which only prints '1'. 253 | distro=$(uname -sv) 254 | ;; 255 | 256 | Minix|DragonFly) 257 | distro="$os $kernel" 258 | 259 | # Minix and DragonFly don't support the escape 260 | # sequences used, clear the exit trap. 261 | trap '' EXIT 262 | ;; 263 | 264 | SunOS) 265 | # Grab the first line of the '/etc/release' file 266 | # discarding everything after '('. 267 | IFS='(' read -r distro _ < /etc/release 268 | ;; 269 | 270 | *) 271 | # Catch all to ensure '$distro' is never blank. 272 | # This also handles the BSDs. 273 | distro="$os $kernel" 274 | ;; 275 | esac 276 | } 277 | 278 | get_kernel() { 279 | case $os in 280 | # Don't print kernel output on some systems as the 281 | # OS name includes it. 282 | *BSD*|Haiku|Minix) ;; 283 | 284 | *) 285 | # '$kernel' is the cached output of 'uname -r'. 286 | log kernel "$kernel" >&6 287 | ;; 288 | esac 289 | } 290 | 291 | get_host() { 292 | case $os in 293 | Linux*) 294 | # Despite what these files are called, version doesn't 295 | # always contain the version nor does name always contain 296 | # the name. 297 | read -r name < /sys/devices/virtual/dmi/id/product_name 298 | read -r version < /sys/devices/virtual/dmi/id/product_version 299 | read -r model < /sys/firmware/devicetree/base/model 300 | 301 | host="$name $version $model" 302 | ;; 303 | 304 | Darwin*|FreeBSD*|DragonFly*) 305 | host=$(sysctl -n hw.model) 306 | ;; 307 | 308 | NetBSD*) 309 | host=$(sysctl -n machdep.dmi.system-vendor \ 310 | machdep.dmi.system-product) 311 | ;; 312 | 313 | *BSD*) 314 | host=$(sysctl -n hw.vendor hw.product) 315 | ;; 316 | esac 317 | 318 | # Turn the host string into an argument list so we can iterate 319 | # over it and remove OEM strings and other information which 320 | # shouldn't be displayed. 321 | # 322 | # Disable the shellcheck warning for word-splitting 323 | # as it's safe and intended ('set -f' disables globbing). 324 | # shellcheck disable=2046,2086 325 | { 326 | set -f 327 | set +f -- $host 328 | host= 329 | } 330 | 331 | # Iterate over the host string word by word as a means of stripping 332 | # unwanted and OEM information from the string as a whole. 333 | # 334 | # This could have been implemented using a long 'sed' command with 335 | # a list of word replacements, however I want to show that something 336 | # like this is possible in pure sh. 337 | # 338 | # This string reconstruction is needed as some OEMs either leave the 339 | # identification information as "To be filled by OEM", "Default", 340 | # "undefined" etc and we shouldn't print this to the screen. 341 | for word; do 342 | # This works by reconstructing the string by excluding words 343 | # found in the "blacklist" below. Only non-matches are appended 344 | # to the final host string. 345 | case $word in 346 | To | [Bb]e | [Ff]illed | [Bb]y | O.E.M. | OEM |\ 347 | Not | Applicable | Specified | System | Product | Name |\ 348 | Version | Undefined | Default | string | INVALID | � | os ) 349 | continue 350 | ;; 351 | esac 352 | 353 | host="$host$word " 354 | done 355 | 356 | # '$arch' is the cached output from 'uname -m'. 357 | log host "${host:-$arch}" >&6 358 | } 359 | 360 | get_uptime() { 361 | # Uptime works by retrieving the data in total seconds and then 362 | # converting that data into days, hours and minutes using simple 363 | # math. 364 | case $os in 365 | Linux*|Minix*) 366 | IFS=. read -r s _ < /proc/uptime 367 | ;; 368 | 369 | Darwin*|*BSD*|DragonFly*) 370 | s=$(sysctl -n kern.boottime) 371 | 372 | # Extract the uptime in seconds from the following output: 373 | # [...] { sec = 1271934886, usec = 667779 } Thu Apr 22 12:14:46 2010 374 | s=${s#*=} 375 | s=${s%,*} 376 | 377 | # The uptime format from 'sysctl' needs to be subtracted from 378 | # the current time in seconds. 379 | s=$(($(date +%s) - s)) 380 | ;; 381 | 382 | Haiku) 383 | # The boot time is returned in microseconds, convert it to 384 | # regular seconds. 385 | s=$(($(system_time) / 1000000)) 386 | ;; 387 | 388 | SunOS) 389 | # Split the output of 'kstat' on '.' and any white-space 390 | # which exists in the command output. 391 | # 392 | # The output is as follows: 393 | # unix:0:system_misc:snaptime 14809.906993005 394 | # 395 | # The parser extracts: ^^^^^ 396 | IFS=' .' read -r _ s _ <<-EOF 397 | $(kstat -p unix:0:system_misc:snaptime) 398 | EOF 399 | ;; 400 | esac 401 | 402 | # Convert the uptime from seconds into days, hours and minutes. 403 | d=$((s / 60 / 60 / 24)) 404 | h=$((s / 60 / 60 % 24)) 405 | m=$((s / 60 % 60)) 406 | 407 | # Only append days, hours and minutes if they're non-zero. 408 | [ "$d" = 0 ] || uptime="${uptime}${d}d " 409 | [ "$h" = 0 ] || uptime="${uptime}${h}h " 410 | [ "$m" = 0 ] || uptime="${uptime}${m}m " 411 | 412 | log uptime "${uptime:-0m}" >&6 413 | } 414 | 415 | get_pkgs() { 416 | # This is just a simple wrapper around 'command -v' to avoid 417 | # spamming '>/dev/null' throughout this function. 418 | has() { command -v "$1" >/dev/null; } 419 | 420 | # This works by first checking for which package managers are 421 | # installed and finally by printing each package manager's 422 | # package list with each package one per line. 423 | # 424 | # The output from this is then piped to 'wc -l' to count each 425 | # line, giving us the total package count of whatever package 426 | # managers are installed. 427 | # 428 | # Backticks are *required* here as '/bin/sh' on macOS is 429 | # 'bash 3.2' and it can't handle the following: 430 | # 431 | # var=$( 432 | # code here 433 | # ) 434 | # 435 | # shellcheck disable=2006 436 | packages=` 437 | case $os in 438 | Linux*) 439 | # Commands which print packages one per line. 440 | has bonsai && bonsai list 441 | has crux && pkginfo -i 442 | has pacman-key && pacman -Qq 443 | has dpkg && dpkg-query -f '.\n' -W 444 | has rpm && rpm -qa 445 | has xbps-query && xbps-query -l 446 | has apk && apk info 447 | has guix && guix package --list-installed 448 | has opkg && opkg list-installed 449 | 450 | # Directories containing packages. 451 | has kiss && printf '%s\n' /var/db/kiss/installed/*/ 452 | has brew && printf '%s\n' "$(brew --cellar)/"* 453 | has emerge && printf '%s\n' /var/db/pkg/*/*/ 454 | has pkgtool && printf '%s\n' /var/log/packages/* 455 | 456 | # 'nix' requires two commands. 457 | has nix-store && { 458 | nix-store -q --requisites /run/current-system/sw 459 | nix-store -q --requisites ~.nix-profile 460 | } 461 | ;; 462 | 463 | Darwin*) 464 | # Commands which print packages one per line. 465 | has pkgin && pkgin list 466 | 467 | # Directories containing packages. 468 | has brew && printf '%s\n' /usr/local/Cellar/* 469 | 470 | # 'port' prints a single line of output to 'stdout' 471 | # when no packages are installed and exits with 472 | # success causing a false-positive of 1 package 473 | # installed. 474 | # 475 | # 'port' should really exit with a non-zero code 476 | # in this case to allow scripts to cleanly handle 477 | # this behavior. 478 | has port && { 479 | pkg_list=$(port installed) 480 | 481 | [ "$pkg_list" = "No ports are installed." ] || 482 | printf '%s\n' "$pkg_list" 483 | } 484 | ;; 485 | 486 | FreeBSD*|DragonFly*) 487 | pkg info 488 | ;; 489 | 490 | OpenBSD*) 491 | printf '%s\n' /var/db/pkg/*/ 492 | ;; 493 | 494 | NetBSD*) 495 | pkg_info 496 | ;; 497 | 498 | Haiku) 499 | printf '%s\n' /boot/system/package-links/* 500 | ;; 501 | 502 | Minix) 503 | printf '%s\n' /usr/pkg/var/db/pkg/*/ 504 | ;; 505 | 506 | SunOS) 507 | has pkginfo && pkginfo -i 508 | has pkg && pkg list 509 | ;; 510 | esac | wc -l 511 | ` 512 | 513 | [ "$packages" -gt 1 ] && log pkgs "$packages" >&6 514 | } 515 | 516 | get_memory() { 517 | case $os in 518 | # Used memory is calculated using the following "formula": 519 | # MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable 520 | # Source: https://github.com/KittyKatt/screenFetch/issues/386 521 | Linux*) 522 | # Parse the '/proc/meminfo' file splitting on ':' and 'k'. 523 | # The format of the file is 'key: 000kB' and an additional 524 | # split is used on 'k' to filter out 'kB'. 525 | while IFS=':k ' read -r key val _; do 526 | case $key in 527 | MemTotal) 528 | mem_used=$((mem_used + val)) 529 | mem_full=$val 530 | ;; 531 | 532 | Shmem) 533 | mem_used=$((mem_used + val)) 534 | ;; 535 | 536 | MemFree|Buffers|Cached|SReclaimable) 537 | mem_used=$((mem_used - val)) 538 | ;; 539 | esac 540 | done < /proc/meminfo 541 | 542 | mem_used=$((mem_used / 1024)) 543 | mem_full=$((mem_full / 1024)) 544 | ;; 545 | 546 | # Used memory is calculated using the following "formula": 547 | # (wired + active + occupied) * 4 / 1024 548 | Darwin*) 549 | mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024)) 550 | 551 | # Parse the 'vmstat' file splitting on ':' and '.'. 552 | # The format of the file is 'key: 000.' and an additional 553 | # split is used on '.' to filter it out. 554 | while IFS=:. read -r key val; do 555 | case $key in 556 | *' wired'*|*' active'*|*' occupied'*) 557 | mem_used=$((mem_used + ${val:-0})) 558 | ;; 559 | esac 560 | 561 | # Using '<<-EOF' is the only way to loop over a command's 562 | # output without the use of a pipe ('|'). 563 | # This ensures that any variables defined in the while loop 564 | # are still accessible in the script. 565 | done <<-EOF 566 | $(vm_stat) 567 | EOF 568 | 569 | mem_used=$((mem_used * 4 / 1024)) 570 | ;; 571 | 572 | OpenBSD*) 573 | mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) 574 | 575 | # This is a really simpler parser for 'vmstat' which grabs 576 | # the used memory amount in a lazy way. 'vmstat' prints 3 577 | # lines of output with the needed value being stored in the 578 | # final line. 579 | # 580 | # This loop simply grabs the 3rd element of each line until 581 | # the EOF is reached. Each line overwrites the value of the 582 | # previous one so we're left with what we wanted. This isn't 583 | # slow as only 3 lines are parsed. 584 | while read -r _ _ line _; do 585 | mem_used=${line%%M} 586 | 587 | # Using '<<-EOF' is the only way to loop over a command's 588 | # output without the use of a pipe ('|'). 589 | # This ensures that any variables defined in the while loop 590 | # are still accessible in the script. 591 | done <<-EOF 592 | $(vmstat) 593 | EOF 594 | ;; 595 | 596 | # Used memory is calculated using the following "formula": 597 | # mem_full - ((inactive + free + cache) * page_size / 1024) 598 | FreeBSD*|DragonFly*) 599 | mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) 600 | 601 | # Use 'set --' to store the output of the command in the 602 | # argument list. POSIX sh has no arrays but this is close enough. 603 | # 604 | # Disable the shellcheck warning for word-splitting 605 | # as it's safe and intended ('set -f' disables globbing). 606 | # shellcheck disable=2046 607 | { 608 | set -f 609 | set +f -- $(sysctl -n hw.pagesize \ 610 | vm.stats.vm.v_inactive_count \ 611 | vm.stats.vm.v_free_count \ 612 | vm.stats.vm.v_cache_count) 613 | } 614 | 615 | # Calculate the amount of used memory. 616 | # $1: hw.pagesize 617 | # $2: vm.stats.vm.v_inactive_count 618 | # $3: vm.stats.vm.v_free_count 619 | # $4: vm.stats.vm.v_cache_count 620 | mem_used=$((mem_full - (($2 + $3 + $4) * $1 / 1024 / 1024))) 621 | ;; 622 | 623 | NetBSD*) 624 | mem_full=$(($(sysctl -n hw.physmem64) / 1024 / 1024)) 625 | 626 | # NetBSD implements a lot of the Linux '/proc' filesystem, 627 | # this uses the same parser as the Linux memory detection. 628 | while IFS=':k ' read -r key val _; do 629 | case $key in 630 | MemFree) 631 | mem_free=$((val / 1024)) 632 | break 633 | ;; 634 | esac 635 | done < /proc/meminfo 636 | 637 | mem_used=$((mem_full - mem_free)) 638 | ;; 639 | 640 | Haiku) 641 | # Read the first line of 'sysinfo -mem' splitting on 642 | # '(', ' ', and ')'. The needed information is then 643 | # stored in the 5th and 7th elements. Using '_' "consumes" 644 | # an element allowing us to proceed to the next one. 645 | # 646 | # The parsed format is as follows: 647 | # 3501142016 bytes free (used/max 792645632 / 4293787648) 648 | IFS='( )' read -r _ _ _ _ mem_used _ mem_full <<-EOF 649 | $(sysinfo -mem) 650 | EOF 651 | 652 | mem_used=$((mem_used / 1024 / 1024)) 653 | mem_full=$((mem_full / 1024 / 1024)) 654 | ;; 655 | 656 | Minix) 657 | # Minix includes the '/proc' filesystem though the format 658 | # differs from Linux. The '/proc/meminfo' file is only a 659 | # single line with space separated elements and elements 660 | # 2 and 3 contain the total and free memory numbers. 661 | read -r _ mem_full mem_free _ < /proc/meminfo 662 | 663 | mem_used=$(((mem_full - mem_free) / 1024)) 664 | mem_full=$(( mem_full / 1024)) 665 | ;; 666 | 667 | SunOS) 668 | hw_pagesize=$(pagesize) 669 | 670 | # 'kstat' outputs memory in the following format: 671 | # unix:0:system_pages:pagestotal 1046397 672 | # unix:0:system_pages:pagesfree 885018 673 | # 674 | # This simply uses the first "element" (white-space 675 | # separated) as the key and the second element as the 676 | # value. 677 | # 678 | # A variable is then assigned based on the key. 679 | while read -r key val; do 680 | case $key in 681 | *total) pages_full=$val ;; 682 | *free) pages_free=$val ;; 683 | esac 684 | done <<-EOF 685 | $(kstat -p unix:0:system_pages:pagestotal \ 686 | unix:0:system_pages:pagesfree) 687 | EOF 688 | 689 | mem_full=$((pages_full * hw_pagesize / 1024 / 1024)) 690 | mem_free=$((pages_free * hw_pagesize / 1024 / 1024)) 691 | mem_used=$((mem_full - mem_free)) 692 | ;; 693 | esac 694 | 695 | log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6 696 | } 697 | 698 | get_wm() { 699 | case $os in 700 | # Don't display window manager on macOS. 701 | Darwin*) ;; 702 | 703 | *) 704 | # xprop can be used to grab the window manager's properties 705 | # which contains the window manager's name under '_NET_WM_NAME'. 706 | # 707 | # The upside to using 'xprop' is that you don't need to hardcode 708 | # a list of known window manager names. The downside is that 709 | # not all window managers conform to setting the '_NET_WM_NAME' 710 | # atom.. 711 | # 712 | # List of window managers which fail to set the name atom: 713 | # catwm, fvwm, dwm, 2bwm, monster, wmaker and sowm [mine! ;)]. 714 | # 715 | # The final downside to this approach is that it does _not_ 716 | # support Wayland environments. The only solution which supports 717 | # Wayland is the 'ps' parsing mentioned below. 718 | # 719 | # A more naive implementation is to parse the last line of 720 | # '~/.xinitrc' to extract the second white-space separated 721 | # element. 722 | # 723 | # The issue with an approach like this is that this line data 724 | # does not always equate to the name of the window manager and 725 | # could in theory be _anything_. 726 | # 727 | # This also fails when the user launches xorg through a display 728 | # manager or other means. 729 | # 730 | # 731 | # Another naive solution is to parse 'ps' with a hardcoded list 732 | # of window managers to detect the current window manager (based 733 | # on what is running). 734 | # 735 | # The issue with this approach is the need to hardcode and 736 | # maintain a list of known window managers. 737 | # 738 | # Another issue is that process names do not always equate to 739 | # the name of the window manager. False-positives can happen too. 740 | # 741 | # This is the only solution which supports Wayland based 742 | # environments sadly. It'd be nice if some kind of standard were 743 | # established to identify Wayland environments. 744 | # 745 | # pfetch's goal is to remain _simple_, if you'd like a "full" 746 | # implementation of window manager detection use 'neofetch'. 747 | # 748 | # Neofetch use a combination of 'xprop' and 'ps' parsing to 749 | # support all window managers (including non-conforming and 750 | # Wayland) though it's a lot more complicated! 751 | 752 | # Don't display window manager if X isn't running. 753 | [ "$DISPLAY" ] || return 754 | 755 | # This is a two pass call to xprop. One call to get the window 756 | # manager's ID and another to print its properties. 757 | command -v xprop && { 758 | # The output of the ID command is as follows: 759 | # _NET_SUPPORTING_WM_CHECK: window id # 0x400000 760 | # 761 | # To extract the ID, everything before the last space 762 | # is removed. 763 | id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK) 764 | id=${id##* } 765 | 766 | # The output of the property command is as follows: 767 | # _NAME 8t 768 | # _NET_WM_PID = 252 769 | # _NET_WM_NAME = "bspwm" 770 | # _NET_SUPPORTING_WM_CHECK: window id # 0x400000 771 | # WM_CLASS = "wm", "Bspwm" 772 | # 773 | # To extract the name, everything before '_NET_WM_NAME = \"' 774 | # is removed and everything after the next '"' is removed. 775 | wm=$(xprop -id "$id" -notype -len 25 -f _NET_WM_NAME 8t) 776 | 777 | # Handle cases of a window manager _not_ populating the 778 | # '_NET_WM_NAME' atom. Display nothing in this case. 779 | case $wm in 780 | *'_NET_WM_NAME = '*) 781 | wm=${wm##*_NET_WM_NAME = \"} 782 | wm=${wm%%\"*} 783 | ;; 784 | 785 | *) 786 | # Fallback to checking the process list 787 | # for the select few window managers which 788 | # don't set '_NET_WM_NAME'. 789 | # 790 | # TODO: This is currently limited to 'grep' 791 | # implementations providing the '-o' 792 | # flag. This needs to be replaced with 793 | # a command which searches for a list 794 | # of strings and returns _only_ the 795 | # first match's contents (also ensuring 796 | # the search itself isn't matched). 797 | # 798 | # A generic parser isn't possible as 799 | # the output of 'ps' is _not_ the same 800 | # between implementations and across 801 | # operating systems. 802 | # 803 | # The simple search method above works 804 | # regardless of 'ps' implementation. 805 | # 806 | # Disable the shellcheck warning about using 807 | # 'pgrep' instead of 'ps | grep' as 'pgrep' 808 | # is not always available. 809 | # shellcheck disable=2009 810 | wm=$(ps x | grep -o \ 811 | -e '[c]atwm' \ 812 | -e '[f]vwm' \ 813 | -e '[d]wm' \ 814 | -e '[2]bwm' \ 815 | -e '[m]onsterwm' \ 816 | -e '[w]maker' \ 817 | -e '[s]owm') 818 | ;; 819 | esac 820 | } 821 | ;; 822 | esac 823 | 824 | log wm "$wm" >&6 825 | } 826 | 827 | 828 | get_de() { 829 | # This only supports Xorg related desktop environments though 830 | # this is fine as knowing the desktop envrionment on Windows, 831 | # macOS etc is useless (they'll always report the same value). 832 | # 833 | # Display the value of '$XDG_CURRENT_DESKTOP', if it's empty, 834 | # display the value of '$DESKTOP_SESSION'. 835 | log de "${XDG_CURRENT_DESKTOP:-$DESKTOP_SESSION}" >&6 836 | } 837 | 838 | get_shell() { 839 | # Display the basename of the '$SHELL' environment variable. 840 | log shell "${SHELL##*/}" >&6 841 | } 842 | 843 | get_editor() { 844 | # Display the value of '$VISUAL', if it's empty, display the 845 | # value of '$EDITOR'. 846 | log editor "${VISUAL:-$EDITOR}" >&6 847 | } 848 | 849 | get_palette() { 850 | # Print the first 8 terminal colors. This uses the existing 851 | # sequences to change text color with a sequence prepended 852 | # to reverse the foreground and background colors. 853 | # 854 | # This allows us to save hardcoding a second set of sequences 855 | # for background colors. 856 | palette=" $c1 $c2 $c3 $c4 $c5 $c6 $c7 " 857 | 858 | # Print the palette with a newline before and after. 859 | # The '\033[%sC' moves the text to the right, the 860 | # length of the ascii art. 861 | printf '\n[%sC%s\n' "${ascii_width-1}" "$palette" >&6 862 | } 863 | 864 | get_ascii() { 865 | # This is a simple function to read the contents of 866 | # an ascii file from 'stdin'. It allows for the use 867 | # of '<<-EOF' to prevent the break in indentation in 868 | # this source code. 869 | # 870 | # This function also sets the text colors according 871 | # to the ascii color. 872 | read_ascii() { 873 | # 'PF_COL1': Set the info name color according to ascii color. 874 | # 'PF_COL3': Set the title color to some other color. ¯\_(ツ)_/¯ 875 | PF_COL1=${PF_COL1:-${1:-7}} 876 | PF_COL3=${PF_COL3:-$((${1:-7}%8+1))} 877 | 878 | # POSIX sh has no 'var+=' so 'var=${var}append' is used. What's 879 | # interesting is that 'var+=' _is_ supported inside '$(())' 880 | # (arithmetic) though there's no support for 'var++/var--'. 881 | # 882 | # There is also no $'\n' to add a "literal"(?) newline to the 883 | # string. The simplest workaround being to break the line inside 884 | # the string (though this has the caveat of breaking indentation). 885 | while IFS= read -r line; do 886 | ascii="$ascii$line 887 | " 888 | done 889 | } 890 | 891 | # This checks for ascii art in the following order: 892 | # '$1': Argument given to 'get_ascii()' directly. 893 | # '$PF_ASCII': Environment variable set by user. 894 | # '$distro': The detected distribution name. 895 | # '$os': The name of the operating system/kernel. 896 | # 897 | # NOTE: Each ascii art below is indented using tabs, this 898 | # allows indentation to continue naturally despite 899 | # the use of '<<-EOF'. 900 | case ${1:-${PF_ASCII:-${distro:-$os}}} in 901 | [Aa]lpine*) 902 | read_ascii 4 <<-EOF 903 | ${c4} /\\ /\\ 904 | /${c7}/ ${c4}\\ \\ 905 | /${c7}/ ${c4}\\ \\ 906 | /${c7}// ${c4}\\ \\ 907 | ${c7}// ${c4}\\ \\ 908 | \\ 909 | EOF 910 | ;; 911 | 912 | [Aa]ndroid*) 913 | read_ascii 2 <<-EOF 914 | ${c2} ;, ,; 915 | ';,.-----.,;' 916 | ,' ', 917 | / O O \\ 918 | | | 919 | '-----------------' 920 | EOF 921 | ;; 922 | 923 | [Aa]rch*) 924 | read_ascii 4 <<-EOF 925 | ${c6} /\\ 926 | / \\ 927 | /\\ \\ 928 | ${c4} / \\ 929 | / ,, \\ 930 | / | | -\\ 931 | /_-'' ''-_\\ 932 | EOF 933 | ;; 934 | 935 | [Aa]rco*) 936 | read_ascii 4 <<-EOF 937 | ${c4} /\\ 938 | / \\ 939 | / /\\ \\ 940 | / / \\ \\ 941 | / / \\ \\ 942 | / / _____\\ \\ 943 | /_/ \`----.\\_\\ 944 | EOF 945 | ;; 946 | 947 | [Aa]rtix*) 948 | read_ascii 6 <<-EOF 949 | ${c4} /\\ 950 | / \\ 951 | /\`'.,\\ 952 | / ', 953 | / ,\`\\ 954 | / ,.'\`. \\ 955 | /.,'\` \`'.\\ 956 | EOF 957 | ;; 958 | 959 | [Cc]ent[Oo][Ss]*) 960 | read_ascii 5 <<-EOF 961 | ${c2} ____${c3}^${c5}____ 962 | ${c2} |\\ ${c3}|${c5} /| 963 | ${c2} | \\ ${c3}|${c5} / | 964 | ${c5}<---- ${c4}----> 965 | ${c4} | / ${c2}|${c3} \\ | 966 | ${c4} |/__${c2}|${c3}__\\| 967 | ${c2} v 968 | EOF 969 | ;; 970 | 971 | [Dd]ebian*) 972 | read_ascii 1 <<-EOF 973 | ${c1} _____ 974 | / __ \\ 975 | | / | 976 | | \\___- 977 | -_ 978 | --_ 979 | EOF 980 | ;; 981 | 982 | [Dd]ragon[Ff]ly*) 983 | read_ascii 1 <<-EOF 984 | ,${c1}_${c7}, 985 | ('-_${c1}|${c7}_-') 986 | >--${c1}|${c7}--< 987 | (_-'${c1}|${c7}'-_) 988 | ${c1}| 989 | | 990 | | 991 | EOF 992 | ;; 993 | 994 | [Ee]lementary*) 995 | read_ascii <<-EOF 996 | ${c7} _______ 997 | / ____ \\ 998 | / | / /\\ 999 | |__\\ / / | 1000 | \\ /__/ / 1001 | \\_______/ 1002 | EOF 1003 | ;; 1004 | 1005 | [Ff]edora*) 1006 | read_ascii 4 <<-EOF 1007 | ${c7} _____ 1008 | / __)${c4}\\${c7} 1009 | | / ${c4}\\ \\${c7} 1010 | ${c4}__${c7}_| |_${c4}_/ /${c7} 1011 | ${c4}/ ${c7}(_ _)${c4}_/${c7} 1012 | ${c4}/ /${c7} | | 1013 | ${c4}\\ \\${c7}__/ | 1014 | ${c4}\\${c7}(_____/ 1015 | EOF 1016 | ;; 1017 | 1018 | [Ff]ree[Bb][Ss][Dd]*) 1019 | read_ascii 1 <<-EOF 1020 | ${c1}/\\,-'''''-,/\\ 1021 | \\_) (_/ 1022 | | | 1023 | | | 1024 | ; ; 1025 | '-_____-' 1026 | EOF 1027 | ;; 1028 | 1029 | [Gg]entoo*) 1030 | read_ascii 5 <<-EOF 1031 | ${c5} _-----_ 1032 | ( \\ 1033 | \\ 0 \\ 1034 | ${c7} \\ ) 1035 | / _/ 1036 | ( _- 1037 | \\____- 1038 | EOF 1039 | ;; 1040 | 1041 | [Gg]uix[Ss][Dd]*|[Gg]uix*) 1042 | read_ascii 3 <<-EOF 1043 | ${c3}|.__ __.| 1044 | |__ \\ / __| 1045 | \\ \\ / / 1046 | \\ \\ / / 1047 | \\ \\ / / 1048 | \\ \\/ / 1049 | \\__/ 1050 | EOF 1051 | ;; 1052 | 1053 | [Hh]aiku*) 1054 | read_ascii 3 <<-EOF 1055 | ${c3} ,^, 1056 | / \\ 1057 | *--_ ; ; _--* 1058 | \\ '" "' / 1059 | '. .' 1060 | .-'" "'-. 1061 | '-.__. .__.-' 1062 | |_| 1063 | EOF 1064 | ;; 1065 | 1066 | [Hh]yperbola*) 1067 | read_ascii <<-EOF 1068 | ${c7} |\`__.\`/ 1069 | \____/ 1070 | .--. 1071 | / \\ 1072 | / ___ \\ 1073 | / .\` \`.\\ 1074 | /.\` \`.\\ 1075 | EOF 1076 | ;; 1077 | 1078 | [Ll]inux*[Ll]ite*|[Ll]ite*) 1079 | read_ascii 3 <<-EOF 1080 | ${c3} /\\ 1081 | / \\ 1082 | / ${c7}/ ${c3}/ 1083 | > ${c7}/ ${c3}/ 1084 | \\ ${c7}\\ ${c3}\\ 1085 | \\_${c7}\\${c3}_\\ 1086 | ${c7} \\ 1087 | EOF 1088 | ;; 1089 | 1090 | [Ll]inux*[Mm]int*|[Mm]int) 1091 | read_ascii 2 <<-EOF 1092 | ${c2} ___________ 1093 | |_ \\ 1094 | | ${c7}| _____ ${c2}| 1095 | | ${c7}| | | | ${c2}| 1096 | | ${c7}| | | | ${c2}| 1097 | | ${c7}\\__${c7}___/ ${c2}| 1098 | \\_________/ 1099 | EOF 1100 | ;; 1101 | 1102 | 1103 | [Ll]inux*) 1104 | read_ascii 4 <<-EOF 1105 | ${c4} ___ 1106 | (${c7}.· ${c4}| 1107 | (${c5}<> ${c4}| 1108 | / ${c7}__ ${c4}\\ 1109 | ( ${c7}/ \\ ${c4}/| 1110 | ${c5}_${c4}/\\ ${c7}__)${c4}/${c5}_${c4}) 1111 | ${c5}\/${c4}-____${c5}\/ 1112 | EOF 1113 | ;; 1114 | 1115 | [Mm]ac[Oo][Ss]*|[Dd]arwin*) 1116 | read_ascii 1 <<-EOF 1117 | ${c1} .:' 1118 | _ :'_ 1119 | ${c2} .'\`_\`-'_\`\`. 1120 | :________.-' 1121 | ${c3}:_______: 1122 | ${c4} :_______\`-; 1123 | ${c5} \`._.-._.' 1124 | EOF 1125 | ;; 1126 | 1127 | [Mm]ageia*) 1128 | read_ascii 2 <<-EOF 1129 | ${c6} * 1130 | * 1131 | ** 1132 | ${c7} /\\__/\\ 1133 | / \\ 1134 | \\ / 1135 | \\____/ 1136 | EOF 1137 | ;; 1138 | 1139 | [Mm]anjaro*) 1140 | read_ascii 2 <<-EOF 1141 | ${c2}||||||||| |||| 1142 | ||||||||| |||| 1143 | |||| |||| 1144 | |||| |||| |||| 1145 | |||| |||| |||| 1146 | |||| |||| |||| 1147 | |||| |||| |||| 1148 | EOF 1149 | ;; 1150 | 1151 | [Mm]inix*) 1152 | read_ascii 4 <<-EOF 1153 | ${c4} ,, ,, 1154 | ;${c7},${c4} ', ,' ${c7},${c4}; 1155 | ; ${c7}',${c4} ',,' ${c7},'${c4} ; 1156 | ; ${c7}',${c4} ${c7},'${c4} ; 1157 | ; ${c7};, '' ,;${c4} ; 1158 | ; ${c7};${c4};${c7}',,'${c4};${c7};${c4} ; 1159 | ', ${c7};${c4};; ;;${c7};${c4} ,' 1160 | '${c7};${c4}' '${c7};${c4}' 1161 | EOF 1162 | ;; 1163 | 1164 | [Mm][Xx]*) 1165 | read_ascii <<-EOF 1166 | ${c7} \\\\ / 1167 | \\\\/ 1168 | \\\\ 1169 | /\\/ \\\\ 1170 | / \\ /\\ 1171 | / \\/ \\ 1172 | /__________\\ 1173 | EOF 1174 | ;; 1175 | 1176 | [Nn]et[Bb][Ss][Dd]*) 1177 | read_ascii 3 <<-EOF 1178 | ${c7}\\\\${c3}\`-______,----__ 1179 | ${c7} \\\\ ${c3}__,---\`_ 1180 | ${c7} \\\\ ${c3}\`.____ 1181 | ${c7} \\\\${c3}-______,----\`- 1182 | ${c7} \\\\ 1183 | \\\\ 1184 | \\\\ 1185 | EOF 1186 | ;; 1187 | 1188 | [Nn]ix[Oo][Ss]*) 1189 | read_ascii 4 <<-EOF 1190 | ${c4} \\\\ \\\\ // 1191 | ==\\\\__\\\\/ // 1192 | // \\\\// 1193 | ==// //== 1194 | //\\\\___// 1195 | // /\\\\ \\\\== 1196 | // \\\\ \\\\ 1197 | EOF 1198 | ;; 1199 | 1200 | [Oo]pen[Bb][Ss][Dd]*) 1201 | read_ascii 3 <<-EOF 1202 | ${c3} _____ 1203 | \\- -/ 1204 | \\_/ \\ 1205 | | ${c7}O O${c3} | 1206 | |_ < ) 3 ) 1207 | / \\ / 1208 | /-_____-\\ 1209 | EOF 1210 | ;; 1211 | 1212 | [Oo]penSUSE*|[Oo]pen*SUSE*|SUSE*|suse*) 1213 | read_ascii 2 <<-EOF 1214 | ${c2} _______ 1215 | __| __ \\ 1216 | / .\\ \\ 1217 | \\__/ | 1218 | _______| 1219 | \\_______ 1220 | __________/ 1221 | EOF 1222 | ;; 1223 | 1224 | [Pp]arabola*) 1225 | read_ascii 5 <<-EOF 1226 | ${c5} __ __ __ _ 1227 | .\`_//_//_/ / \`. 1228 | / .\` 1229 | / .\` 1230 | /.\` 1231 | /\` 1232 | EOF 1233 | ;; 1234 | 1235 | [Pp]op!_[Oo][Ss]*) 1236 | read_ascii 6 <<-EOF 1237 | ${c6}______ 1238 | \\ _ \\ __ 1239 | \\ \\ \\ \\ / / 1240 | \\ \\_\\ \\ / / 1241 | \\ ___\\ /_/ 1242 | \\ \\ _ 1243 | __\\_\\__(_)_ 1244 | (___________) 1245 | EOF 1246 | ;; 1247 | 1248 | [Pp]ure[Oo][Ss]*) 1249 | read_ascii <<-EOF 1250 | ${c7} _____________ 1251 | | _________ | 1252 | | | | | 1253 | | | | | 1254 | | |_________| | 1255 | |_____________| 1256 | EOF 1257 | ;; 1258 | 1259 | [Ss]lackware*) 1260 | read_ascii 4 <<-EOF 1261 | ${c4} ________ 1262 | / ______| 1263 | | |______ 1264 | \\______ \\ 1265 | ______| | 1266 | | |________/ 1267 | |____________ 1268 | EOF 1269 | ;; 1270 | 1271 | [Ss]un[Oo][Ss]|[Ss]olaris*) 1272 | read_ascii 3 <<-EOF 1273 | ${c3} . .; . 1274 | . :; :: ;: . 1275 | .;. .. .. .;. 1276 | .. .. .. .. 1277 | .;, ,;. 1278 | EOF 1279 | ;; 1280 | 1281 | [Uu]buntu*) 1282 | read_ascii 3 <<-EOF 1283 | ${c3} _ 1284 | ---(_) 1285 | _/ --- \\ 1286 | (_) | | 1287 | \\ --- _/ 1288 | ---(_) 1289 | EOF 1290 | ;; 1291 | 1292 | [Vv]oid*) 1293 | read_ascii 2 <<-EOF 1294 | ${c2} _______ 1295 | _ \\______ - 1296 | | \\ ___ \\ | 1297 | | | / \ | | 1298 | | | \___/ | | 1299 | | \\______ \\_| 1300 | -_______\\ 1301 | EOF 1302 | ;; 1303 | 1304 | *) 1305 | # On no match of a distribution ascii art, this function calls 1306 | # itself again, this time to look for a more generic OS related 1307 | # ascii art (KISS Linux -> Linux). 1308 | [ "$1" ] || { 1309 | get_ascii "$os" 1310 | return 1311 | } 1312 | 1313 | printf 'error: %s is not currently supported.\n' "$os" >&6 1314 | printf 'error: Open an issue for support to be added.\n' >&6 1315 | exit 1 1316 | ;; 1317 | esac 1318 | 1319 | # Store the "width" (longest line) and "height" (number of lines) 1320 | # of the ascii art for positioning. This script prints to the screen 1321 | # *almost* like a TUI does. It uses escape sequences to allow dynamic 1322 | # printing of the information through user configuration. 1323 | # 1324 | # Iterate over each line of the ascii art to retrieve the above 1325 | # information. The 'sed' is used to strip 'm' color codes from 1326 | # the ascii art so they don't affect the width variable. 1327 | while read -r line; do 1328 | ascii_height=$((${ascii_height:-0} + 1)) 1329 | 1330 | # This was a ternary operation but they aren't supported in 1331 | # Minix's shell. 1332 | [ "${#line}" -gt "${ascii_width:-0}" ] && 1333 | ascii_width=${#line} 1334 | 1335 | # Using '<<-EOF' is the only way to loop over a command's 1336 | # output without the use of a pipe ('|'). 1337 | # This ensures that any variables defined in the while loop 1338 | # are still accessible in the script. 1339 | done <<-EOF 1340 | $(printf %s "$ascii" | sed 's/\[3.m//g') 1341 | EOF 1342 | 1343 | # Add a gap between the ascii art and the information. 1344 | ascii_width=$((ascii_width + 4)) 1345 | 1346 | # Print the ascii art and position the cursor back where we 1347 | # started prior to printing it. 1348 | # '[1m': Print the ascii in bold. 1349 | # '[m': Clear bold. 1350 | # '[%sA': Move the cursor up '$ascii_height' amount of lines. 1351 | printf '%s[%sA' "$ascii" "$ascii_height" >&6 1352 | } 1353 | 1354 | main() { 1355 | # Hide 'stderr' unless the first argument is '-v'. This saves 1356 | # polluting the script with '2>/dev/null'. 1357 | [ "$1" = -v ] || exec 2>/dev/null 1358 | 1359 | # Hide 'stdout' and selectively print to it using '>&6'. 1360 | # This gives full control over what it displayed on the screen. 1361 | exec 6>&1 >/dev/null 1362 | 1363 | # Ensure that the 'TMPDIR' is writable as heredocs use it and 1364 | # fail without the write permission. This was found to be the 1365 | # case on Android where the temporary directory requires root. 1366 | [ -w "${TMPDIR:-/tmp}" ] || export TMPDIR=~ 1367 | 1368 | # Generic color list. 1369 | # Disable warning about unused variables. 1370 | # shellcheck disable=2034 1371 | { 1372 | c1=''; c2='' 1373 | c3=''; c4='' 1374 | c5=''; c6='' 1375 | c7=''; c8='' 1376 | } 1377 | 1378 | # Avoid text-wrapping from wrecking the program output 1379 | # and hide the cursor to hide its moving around during 1380 | # the printing process. 1381 | # 1382 | # Some terminals don't support these sequences, nor do they 1383 | # silently conceal them if they're printed resulting in 1384 | # partial sequences being printed to the terminal! 1385 | [ "$TERM" = dumb ] || 1386 | [ "$TERM" = minix ] || 1387 | [ "$TERM" = cons25 ] || { 1388 | # '[?7l': Disable line-wrapping. 1389 | # '[?25l': Hide the cursor. 1390 | printf '[?7l[?25l' >&6 1391 | 1392 | # Leave the terminal how we found it on exit or Ctrl+C. 1393 | # '[?7h': Enable line-wrapping. 1394 | # '[?25h': Show the cursor. 1395 | trap 'printf [?7h[?25h >&6' EXIT 1396 | } 1397 | 1398 | # Store the output of 'uname' to avoid calling it multiple times 1399 | # throughout the script. 'read </dev/null || continue 1423 | 1424 | # This was a ternary operation but they aren't supported in 1425 | # Minix's shell. 1426 | [ "${#info}" -gt "${info_length:-0}" ] && 1427 | info_length=${#info} 1428 | done 1429 | 1430 | # Add an additional space of length to act as a gap. 1431 | info_length=$((info_length + 1)) 1432 | 1433 | # Iterate over the above list and run any existing "get_" functions. 1434 | for info; do "get_$info"; done 1435 | } 1436 | 1437 | # Position the cursor below both the ascii art and information lines 1438 | # according to the height of both. If the information exceeds the ascii 1439 | # art in height, don't touch the cursor (0/unset), else move it down 1440 | # N lines. 1441 | # 1442 | # This was a ternary operation but they aren't supported in Minix's shell. 1443 | [ "${info_height:-0}" -lt "${ascii_height:-0}" ] && 1444 | cursor_pos=$((ascii_height - info_height)) 1445 | 1446 | # Print '$cursor_pos' amount of newlines to correctly position the 1447 | # cursor. This used to be a 'printf $(seq X X)' however 'seq' is only 1448 | # typically available (by default) on GNU based systems! 1449 | while [ "${i:=0}" -le "${cursor_pos:-0}" ]; do 1450 | printf '\n' 1451 | i=$((i + 1)) 1452 | done >&6 1453 | } 1454 | 1455 | main "$@" 1456 | -------------------------------------------------------------------------------- /polybar/launchpolybar: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Launches an instance of polybar 3 | 4 | # Terminate already running bar instances 5 | killall -q polybar 6 | 7 | # Wait until the processes have been shut down 8 | while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done 9 | 10 | # Launch Polybar, using default config location ~/.config/polybar/config 11 | polybar bar & 12 | 13 | echo "Polybar launched..." 14 | -------------------------------------------------------------------------------- /polybar/polybattery: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple script to output battery level formatted for polybar 3 | 4 | bat_number=0 5 | acpi=$(acpi -b 2>/dev/null| grep "Battery $bat_number") 6 | ac_adapt=$(acpi -a | awk '{print $2}') 7 | mode=$(echo "$acpi" | awk '{print $3}') 8 | percent=$(echo "$acpi" | awk '{print $4}'| grep -Eo '[0-9]*') 9 | remaining=$(echo "$acpi" | awk '{print $5}') 10 | symbol="" 11 | 12 | 13 | if [ "$mode" = "Discharging," ]; then 14 | symbol='⚡ ' 15 | elif [ "$mode" = "Charging," ]; then 16 | symbol='🔌 ' 17 | elif [ "$mode" = "Unknown," ]; then 18 | if [ "$ac_adapt" = "on-line," ]; then 19 | symbol='⚡ ' 20 | elif [ "$ac_adapt" = "off-line," ]; then 21 | symbol='🔌 ' 22 | fi 23 | else 24 | symbol='🔋 ' 25 | fi 26 | 27 | printf "%s" "$symbol" 28 | 29 | if [ "$percent" -lt 20 ]; then 30 | printf "%%{F#ed0b0b}" 31 | elif [ "$percent" -lt 50 ]; then 32 | printf "%%{F#f2e421}"; 33 | fi 34 | 35 | printf "$percent%%" 36 | 37 | if [ "$mode" = "Discharging," ] || [ "$mode" = "Charging," ] || [ "$ac_adapt" = "off-line," ]; then 38 | echo " ($remaining)" 39 | fi 40 | -------------------------------------------------------------------------------- /polybar/polycpu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Copyright 2014 Pierre Mavro 4 | # Copyright 2014 Vivien Didelot 5 | # Copyright 2014 Andreas Guldstrand 6 | # 7 | # Licensed under the terms of the GNU GPL v3, or any later version. 8 | 9 | use strict; 10 | use warnings; 11 | use utf8; 12 | use Getopt::Long; 13 | 14 | # default values 15 | my $t_warn = $ENV{T_WARN} // 50; 16 | my $t_crit = $ENV{T_CRIT} // 85; 17 | my $cpu_usage = -1; 18 | my $decimals = $ENV{DECIMALS} // 2; 19 | my $label = $ENV{LABEL} // ""; 20 | 21 | sub help { 22 | print "Usage: cpu_usage [-w ] [-c ] [-d ]\n"; 23 | print "-w : warning threshold to become yellow\n"; 24 | print "-c : critical threshold to become red\n"; 25 | print "-d : Use decimals for percentage (default is $decimals) \n"; 26 | exit 0; 27 | } 28 | 29 | GetOptions("help|h" => \&help, 30 | "w=i" => \$t_warn, 31 | "c=i" => \$t_crit, 32 | "d=i" => \$decimals, 33 | ); 34 | 35 | # Get CPU usage 36 | $ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is 37 | open (MPSTAT, 'mpstat 1 1 |') or die; 38 | while () { 39 | if (/^.*\s+(\d+\.\d+)[\s\x00]?$/) { 40 | $cpu_usage = 100 - $1; # 100% - %idle 41 | last; 42 | } 43 | } 44 | close(MPSTAT); 45 | 46 | $cpu_usage eq -1 and die 'Can\'t find CPU information'; 47 | 48 | # Print color, if needed 49 | if ($cpu_usage >= $t_crit) { 50 | print "%{F#ed0b0b}"; 51 | } elsif ($cpu_usage >= $t_warn) { 52 | print "%{F#f2e421}"; 53 | } 54 | print "${label}"; 55 | printf "%.${decimals}f%%\n", $cpu_usage; 56 | 57 | exit 0; 58 | -------------------------------------------------------------------------------- /polybar/polypulsevolume: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Outputs the pulse volume level formatted to be shown in polybar 3 | device=$(pulsedevices | grep "pci-0000_0b" -A 2) 4 | mute=$(echo "$device" | grep "Mute" | awk '{ print $2 }') 5 | vol=$(echo "$device" | grep "front-left" | awk '{ print $5 }') 6 | 7 | if [ "$mute" = "yes" ]; then 8 | echo "🔇 mute" 9 | elif [ "$(echo "$vol" | tr -d "%")" -gt 70 ]; then 10 | echo "🔊 $vol" 11 | elif [ "$(echo "$vol" | tr -d "%")" -gt 35 ]; then 12 | echo "🔉 $vol" 13 | else 14 | echo "🔈 $vol" 15 | fi 16 | #echo "$vol" 17 | -------------------------------------------------------------------------------- /polybar/polysubs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "🐧 $(cat ~/.cache/subs/main) ☕ $(cat ~/.cache/subs/podcast)" 4 | -------------------------------------------------------------------------------- /polybar/polytemp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple script to show the cpu temp formatted to be shown in polybar 3 | 4 | echo "WIP" 5 | temp=$(acpi -t | sed 's/.*, //;s/ degrees //;s/C//') 6 | if [ 1 -eq "$(echo "$temp > 80" | bc)" ]; then 7 | printf "%%{F#ed0b0b}" 8 | elif [ 1 -eq "$(echo "$temp > 60" | bc)" ]; then 9 | printf "%%{F#f2e421}"; 10 | fi 11 | echo "$temp"°C 12 | 13 | -------------------------------------------------------------------------------- /polybar/polytempamd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple script to show the cpu temp formatted to be shown in polybar 3 | 4 | temp=$(sensors | grep "Tdie" | sed "s/Tdie: *+//;s/°C *//") 5 | if [ 1 -eq "$(echo "$temp > 80" | bc)" ]; then 6 | printf "%%{F#ed0b0b}" 7 | elif [ 1 -eq "$(echo "$temp > 60" | bc)" ]; then 8 | printf "%%{F#f2e421}"; 9 | fi 10 | echo "$temp"°C 11 | 12 | -------------------------------------------------------------------------------- /polybar/reloadpolybar: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to reload an instance of polybar 3 | if [ -z "$(pidof polybar)" ]; then 4 | launchpolybar & 5 | else 6 | polybar-msg cmd restart 7 | fi 8 | -------------------------------------------------------------------------------- /prompt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Opens a basic yes/no prompt with dmenu 3 | # This is useful for confirming whether an action should be taken 4 | 5 | if [ "$(printf "No\nYes" | dmenu -i -p "$1")" = "Yes" ]; then 6 | $2 7 | fi 8 | -------------------------------------------------------------------------------- /pulse/pulsedevices: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Lists out the pulse devices and volume data 3 | pactl list sinks | grep 'Name\|Mute\|Volume:' 4 | -------------------------------------------------------------------------------- /pulse/pulsevolctrl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Changes the volume level of an audio track 3 | # Signals an update in polybar for the volume module 4 | 5 | if [ "$1" = "output-vol" ]; then 6 | pactl set-sink-mute "$2" false 7 | pactl set-sink-volume "$2" "$3" 8 | else 9 | pactl set-sink-mute "$2" toggle 10 | fi 11 | 12 | device=$(pulsedevices | grep "pci-0000_0b" -A 2) 13 | vol=$(echo "$device" | grep "front-left" | awk '{ print $5 }' | tr -d "%") 14 | 15 | # Updates volume in bar 16 | polybar-msg hook volume 1 17 | #pkill -SIGTRAP pulseupdate 18 | #pkill -SIGRTMIN+1 i3blocks 19 | #reflemon 20 | 21 | -------------------------------------------------------------------------------- /pulseupdate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | trap 'Update' 5 3 | 4 | Update() { 5 | echo "update" 6 | } 7 | 8 | while true; do 9 | wait 10 | done 11 | -------------------------------------------------------------------------------- /pyshell: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "" | dmenu -i -p "Python" | xargs -0 -I % python -c "import random;print(%)" | xargs -I % notify-send "Result" "%" 3 | -------------------------------------------------------------------------------- /reflemon: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | pkill -SIGTRAP lemonconfig 3 | -------------------------------------------------------------------------------- /rootid: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Outputs the id of the root window 3 | xwininfo -root | awk '/Window id:/{print $4}' 4 | -------------------------------------------------------------------------------- /rssreader: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sfeed_update 3 | url=$(sfeed_plain "$HOME/.sfeed/feeds/"* | dmenu -l 33 -i | \ 4 | sed -n 's@^.* \([a-zA-Z]*://\)\(.*\)$@\1\2@p') 5 | test -n "${url}" && $BROWSER "${url}" 6 | -------------------------------------------------------------------------------- /sch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Opens a dmenu prompt for selecting a search engine and providing a search query 3 | # To avoid issues with spaces and special characters html encoding is applied to the query 4 | 5 | url=$(sort ~/.config/search/search | sed 's/:.*//' | dmenu -i -p "Search Engine" | xargs -I % grep "%:" ~/.config/search/search | sed 's/.*://') 6 | search=$(sort ~/.config/search/search_history | dmenu -i -p "Search") 7 | 8 | # Echo to history file 9 | if [ ! "$(grep -q "$search" < ~/.config/search/search_history)" ]; then 10 | if [ "$(wc -l < ~/.config/search/search_history)" -gt 500 ]; then 11 | sed -i "1s/^/$search\n/;$ d" ~/.config/search/search_history 12 | else 13 | echo "$search" >> ~/.config/search/search_history 14 | fi 15 | fi 16 | 17 | # Open browser if search query provided 18 | if [ -n "$search" ] && [ "$search" != "" ]; then 19 | opnbrow "$1" "$url$(encode "$search")" 20 | fi 21 | -------------------------------------------------------------------------------- /screenshot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Simple script that uses maim to take a screenshot 3 | output=$HOME/pictures/screenshots/"$(date +%s_%h%d_%H:%M:%S).png" 4 | 5 | menu() { 6 | echo "" | dmenu -p "How Long?" | xargs -I _ sleep "_" 7 | } 8 | 9 | case "$1" in 10 | "full") maim "$output" || exit;; 11 | "select") maim -s "$output" || exit ;; 12 | "fulltime") menu && maim "$output" || exit ;; 13 | "selecttime") menu && maim -s "$output" || exit ;; 14 | 15 | esac 16 | 17 | notify-send "Maim" "Screenshot Taken" 18 | -------------------------------------------------------------------------------- /shfm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | esc() { 4 | case $1 in 5 | # vt100 (IL is vt102) (DECTCEM is vt520) 6 | CUD) printf '%s[%sB' "$esc_c" "$2" ;; # cursor down 7 | CUP) printf '%s[%s;%sH' "$esc_c" "$2" "$3" ;; # cursor home 8 | CUU) printf '%s[%sA' "$esc_c" "$2" ;; # cursor up 9 | DECAWM) printf '%s[?7%s' "$esc_c" "$2" ;; # line wrap 10 | DECRC) printf '%s8' "$esc_c" ;; # cursor restore 11 | DECSC) printf '%s7' "$esc_c" ;; # cursor save 12 | DECSTBM) printf '%s[%s;%sr' "$esc_c" "$2" "$3" ;; # scroll region 13 | DECTCEM) printf '%s[?25%s' "$esc_c" "$2" ;; # cursor visible 14 | ED[0-2]) printf '%s[%sJ' "$esc_c" "${1#ED}" ;; # clear screen 15 | EL[0-2]) printf '%s[%sK' "$esc_c" "${1#EL}" ;; # clear line 16 | IL) printf '%s[%sL' "$esc_c" "$2" ;; # insert line 17 | SGR) printf '%s[%s;%sm' "$esc_c" "$2" "$3" ;; # colors 18 | 19 | # xterm (since 1988, supported widely) 20 | screen_alt) printf '%s[?1049%s' "$esc_c" "$2" ;; # alternate buffer 21 | esac 22 | } 23 | 24 | term_setup() { 25 | stty=$(stty -g) 26 | stty -icanon -echo 27 | esc screen_alt h 28 | esc DECAWM l 29 | esc DECTCEM l 30 | esc ED2 31 | esc DECSTBM 1 "$((LINES - 2))" 32 | } 33 | 34 | term_reset() { 35 | esc DECAWM h >&2 36 | esc DECTCEM h >&2 37 | esc ED2 >&2 38 | esc DECSTBM >&2 39 | esc screen_alt l >&2 40 | stty "$stty" 41 | 42 | # needed for cd-on-exit 43 | printf '%s\n' "$PWD" >&1 44 | } 45 | 46 | term_resize() { 47 | # false-positive, behavior intentional, globbing is disabled. 48 | # shellcheck disable=2046 49 | { 50 | set -f 51 | set +f -- $(stty size) 52 | } 53 | 54 | LINES=$1 COLUMNS=$2 55 | 56 | # space for status_line 57 | bottom=$((LINES - 2)) 58 | } 59 | 60 | term_scroll_down() { 61 | case $((y - $#)) in 62 | [0-9]*) return 63 | esac 64 | 65 | y=$((y + 1)) 66 | y2=$((y2 + 1 < bottom ? y2 + 1 : bottom)) 67 | 68 | line_print "$((y - 1))" "$@" 69 | printf '\n' 70 | line_print "$y" "$@" 71 | status_line "$#" 72 | } 73 | 74 | term_scroll_up() { 75 | case $y in 76 | -*|0|1) return 77 | esac 78 | 79 | y=$((y - 1)) 80 | 81 | line_print "$((y + 1))" "$@" 82 | 83 | case $y2 in 84 | 1) esc IL ;; 85 | *) esc CUU; y2=$((y2 > 1 ? y2 - 1 : 1)) 86 | esac 87 | 88 | line_print "$y" "$@" 89 | status_line "$#" 90 | } 91 | 92 | cmd_run() { 93 | stty "$stty" 94 | esc DECTCEM h 95 | esc DECSTBM 96 | esc ED2 97 | "$@" ||: 98 | esc DECSTBM 1 "$((LINES - 2))" 99 | esc DECTCEM l 100 | stty -icanon -echo 101 | hist=2 102 | } 103 | 104 | file_escape() { 105 | tmp=$1 safe= 106 | 107 | # loop over string char by char 108 | while c=${tmp%"${tmp#?}"}; do 109 | case $c in 110 | '') return ;; 111 | [[:cntrl:]]) safe=$safe\? ;; 112 | *) safe=$safe$c ;; 113 | esac 114 | 115 | tmp=${tmp#?} 116 | done 117 | } 118 | 119 | hist_search() { 120 | hist=0 j=1 121 | 122 | for file do 123 | case ${PWD%%/}/$file in 124 | "$old_pwd") y=$j y2=$((j > bottom ? mid : j)) cur=$file 125 | esac 126 | 127 | j=$((j + 1)) 128 | done 129 | } 130 | 131 | list_print() { 132 | esc ED2 133 | esc CUP 134 | 135 | i=1 136 | end=$((bottom + 1)) 137 | mid=$((bottom / 4 < 5 ? 1 : bottom / 4)) 138 | 139 | case $# in 140 | 1) [ -e "$1" ] || set -- empty 141 | esac 142 | 143 | case $hist in 144 | 2) # redraw after cmd run 145 | shift "$((y > y2 ? y - y2 : 0))" 146 | ;; 147 | 148 | 1) # redraw after go-to-parent 149 | hist_search "$@" 150 | shift "$((y >= bottom ? y - mid : 0))" 151 | ;; 152 | 153 | *) # everything else 154 | shift "$((y >= bottom ? y - bottom : 0))" 155 | ;; 156 | esac 157 | 158 | for file do 159 | case $i in 160 | "$y2") esc SGR 0 7 161 | esac 162 | 163 | case $((i - end)) in 164 | -*) 165 | line_format "$file" 166 | esc CUD 167 | ;; 168 | esac 169 | 170 | i=$((i + 1)) 171 | done 172 | 173 | esc CUP "$((y > y2 ? y2 : y))" 174 | } 175 | 176 | redraw() { 177 | list_print "$@" 178 | status_line "$#" 179 | } 180 | 181 | status_line() { 182 | esc DECSC 183 | esc CUP "$LINES" 184 | 185 | case $USER in 186 | root) esc SGR 31 7 ;; 187 | *) esc SGR 34 7 ;; 188 | esac 189 | 190 | printf '%*s\r%s ' "$COLUMNS" "" "($y/$1)" 191 | 192 | case $ltype in 193 | '') printf %s "$PWD" ;; 194 | *) printf %s "$ltype" 195 | esac 196 | 197 | esc SGR 0 0 198 | esc DECRC 199 | } 200 | 201 | prompt() { 202 | esc DECSC 203 | esc CUP "$LINES" 204 | printf %s "$1" 205 | esc DECTCEM h 206 | esc EL0 207 | 208 | case $2 in 209 | r) 210 | stty icanon echo 211 | read -r ans ||: 212 | stty -icanon -echo 213 | ;; 214 | esac 215 | 216 | esc DECRC 217 | esc DECTCEM l 218 | status_line "($y/$#) $PWD" 219 | } 220 | 221 | line_print() { 222 | offset=$1 223 | 224 | case $offset in 225 | "$y") esc SGR 0 7 226 | esac 227 | 228 | shift "$offset" 229 | 230 | case $offset in 231 | "$y") cur=$1 232 | esac 233 | 234 | line_format "$1" 235 | } 236 | 237 | line_format() { 238 | file_escape "$1" 239 | [ -d "$1" ] && esc SGR 1 31 240 | printf %s "$safe" 241 | [ -d "$1" ] && printf / 242 | esc SGR 0 0 243 | esc EL0 244 | printf '\r' 245 | } 246 | 247 | main() { 248 | set -e 249 | 250 | case $1 in 251 | -h|--help) 252 | printf 'shfm -[hv] \n' 253 | exit 0 254 | ;; 255 | 256 | -v|--version) 257 | printf 'shfm 0.4.2\n' 258 | exit 0 259 | ;; 260 | 261 | *) 262 | cd -- "${1:-"$PWD"}" 263 | ;; 264 | esac 265 | 266 | esc_c=$(printf '\033') 267 | bs_char=$(printf '\177') 268 | 269 | set -- * 270 | cur=$1 271 | 272 | term_resize 273 | term_setup 274 | 275 | trap 'term_reset' EXIT INT 276 | trap 'term_resize; term_setup; y=1 y2=1; redraw "$@"' WINCH 277 | 278 | y=1 y2=1 279 | redraw "$@" 280 | 281 | while key=$(dd ibs=1 count=1 2>/dev/null); do 282 | case $key${esc:=0} in 283 | k?|A2) 284 | term_scroll_up "$@" 285 | ;; 286 | 287 | j?|B2) 288 | term_scroll_down "$@" 289 | ;; 290 | 291 | l?|C2|"$esc") # ARROW RIGHT 292 | if [ -d "$cur" ] && cd -- "$cur" >/dev/null 2>&1; then 293 | set -- * 294 | y=1 y2=1 cur=$1 ltype= 295 | redraw "$@" 296 | 297 | elif [ -e "$cur" ]; then 298 | cmd_run "${SHFM_OPENER:="${EDITOR:=vi}"}" "$cur" 299 | redraw "$@" 300 | fi 301 | ;; 302 | 303 | h?|D2|"$bs_char"?) # ARROW LEFT 304 | old_pwd=$PWD 305 | 306 | case $ltype in 307 | '') cd .. || continue ;; 308 | *) ltype= ;; 309 | esac 310 | 311 | set -- * 312 | y=1 y2=1 cur=$1 hist=1 313 | redraw "$@" 314 | ;; 315 | 316 | g?) 317 | case $y in 318 | 1) continue 319 | esac 320 | 321 | y=1 y2=1 cur=$1 322 | redraw "$@" 323 | ;; 324 | 325 | G?) 326 | y=$# 327 | y2=$(($# < bottom ? $# : bottom)) 328 | redraw "$@" 329 | ;; 330 | 331 | .?) 332 | case ${hidden:=1} in 333 | 1) hidden=0; set -- .* ;; 334 | 0) hidden=1; set -- * 335 | esac 336 | 337 | y=1 y2=1 cur=$1 338 | redraw "$@" 339 | ;; 340 | 341 | :?) 342 | prompt "cd: " r 343 | 344 | # false positive, behavior intentional 345 | # shellcheck disable=2088 346 | case $ans in 347 | '~') ans=$HOME ;; 348 | '~/'*) ans=$HOME/${ans#"~/"} 349 | esac 350 | 351 | cd -- "${ans:="$0"}" >/dev/null 2>&1|| continue 352 | set -- * 353 | y=1 y2=1 cur=$1 354 | redraw "$@" 355 | ;; 356 | 357 | /?) 358 | prompt / r 359 | 360 | # word splitting and globbing intentional 361 | # shellcheck disable=2086 362 | set -- $ans* 363 | 364 | case $1$# in 365 | "$ans*1") set -- 'no results' 366 | esac 367 | 368 | y=1 y2=1 cur=$1 ltype="search $PWD/$ans*" 369 | redraw "$@" 370 | status_line "$#" 371 | ;; 372 | 373 | -?) 374 | cd -- "$OLDPWD" >/dev/null 2>&1|| continue 375 | set -- * 376 | y=1 y2=1 cur=$1 377 | redraw "$@" 378 | ;; 379 | 380 | \~?) 381 | cd || continue 382 | set -- * 383 | y=1 y2=1 cur=$1 384 | redraw "$@" 385 | ;; 386 | 387 | \!?) 388 | export SHFM_LEVEL 389 | SHFM_LEVEL=$((SHFM_LEVEL + 1)) 390 | cmd_run "${SHELL:=/bin/sh}" 391 | redraw "$@" 392 | ;; 393 | 394 | \??) 395 | set -- 'j - down' \ 396 | 'k - up' \ 397 | 'l - open file or directory' \ 398 | 'h - go up level' \ 399 | 'g - go to top' \ 400 | 'G - go to bottom' \ 401 | 'q - quit' \ 402 | ': - cd to ' \ 403 | '/ - search current directory *' \ 404 | '- - go to last directory' \ 405 | '~ - go home' \ 406 | '! - spawn shell' \ 407 | '. - toggle hidden files' \ 408 | '? - show keybinds' 409 | 410 | y=1 y2=1 cur=$1 ltype=keybinds 411 | redraw "$@" 412 | status_line "$#" 413 | ;; 414 | 415 | q?) exit 0 ;; 416 | 417 | # handle keys which emit escape sequences 418 | "$esc_c"*) esc=1 ;; 419 | '[1') esc=2 ;; 420 | *) esc=0 ;; 421 | esac 422 | done 423 | } 424 | 425 | main "$@" >/dev/tty 426 | -------------------------------------------------------------------------------- /smenutest: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | selected="$(ls -a | smenu -c -W $'\n' -n20 -x cur 10 -m "Select a file:" -N -q -1 '^\.')" 3 | echo "$selected" 4 | 5 | -------------------------------------------------------------------------------- /songname: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Stays on loop while the script is active 3 | while "true"; do 4 | mpc current > /home/brodie/videos/streaming/sound.txt 5 | mpc idle 6 | done 7 | -------------------------------------------------------------------------------- /songnotification: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | song=$(playerctl metadata --player=mpd --format "Title: {{ xesam:title }}\nArtist: {{ xesam:artist }}\nAlbum: {{ xesam:album }}") 3 | notify-send "Music Player" "$song" --icon=~/.config/spotifyd/spotify.png 4 | -------------------------------------------------------------------------------- /soundboard: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from pynput import keyboard 3 | from pynput.keyboard import Key, Controller 4 | from pydub import AudioSegment 5 | from pydub.playback import play 6 | import json 7 | from os.path import expanduser 8 | 9 | keyboard_controller = Controller() 10 | config_path = expanduser("~") + "/.config/soundboard.json" 11 | bindings = {} 12 | 13 | special_keys = {'f1': Key.f1, 14 | 'f2': Key.f2, 15 | 'f3': Key.f3, 16 | 'f4': Key.f4, 17 | 'f5': Key.f5, 18 | 'f6': Key.f6, 19 | 'f7': Key.f7, 20 | 'f8': Key.f8, 21 | 'f9': Key.f9, 22 | 'f10': Key.f10, 23 | 'f11': Key.f11, 24 | 'f12': Key.f12} 25 | 26 | with open(config_path) as config: 27 | data = json.load(config) 28 | for key in data['bindings']: 29 | if key['key'] in special_keys: 30 | bindings[special_keys[key['key']]] = key['sound'] 31 | else: 32 | bindings[key['key']] = key['sound'] 33 | 34 | def play_song(song): 35 | # Debug Code 36 | # ten_seconds = 3 * 1000 37 | # first_10_seconds = song[:ten_seconds] 38 | # play(first_10_seconds) 39 | play(song) 40 | 41 | def on_press(key): 42 | try: 43 | if key.char in bindings: 44 | song = AudioSegment.from_file(bindings[key.char]) 45 | play_song(song) 46 | except AttributeError: 47 | if key in bindings: 48 | song = AudioSegment.from_file(bindings[key]) 49 | play_song(song) 50 | 51 | # Collect events until released 52 | with keyboard.Listener( 53 | on_press=on_press) as listener: 54 | listener.join() 55 | -------------------------------------------------------------------------------- /stabmux: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Opens up st in tabbed and tmux 3 | tabbed -r 2 st -w '' tmux 4 | -------------------------------------------------------------------------------- /streammusic: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mpc clear 3 | mpc volume 30 4 | mpc random on 5 | mpc repeat on 6 | 7 | case $1 in 8 | "outro") 9 | mpc load Outro 10 | ;; 11 | "intro") 12 | mpc load Intro 13 | ;; 14 | "stream") 15 | mpc load Stream 16 | ;; 17 | "serious") 18 | mpc load SeriousTime 19 | ;; 20 | "pause") 21 | mpc load Pause 22 | ;; 23 | esac 24 | 25 | mpc play 26 | -------------------------------------------------------------------------------- /streamtime: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | while true 3 | do 4 | sleep 1 5 | date "+%H:%M:%S" > ~/.cache/stream/time 6 | done 7 | -------------------------------------------------------------------------------- /stripspace: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Renames a file by stripping out the spaces 3 | newname=$(echo "$1" | sed 's/ /-/g') 4 | mv "$1" "$newname" 5 | -------------------------------------------------------------------------------- /timestamps: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import xml.etree.ElementTree as ET 3 | import json 4 | import time 5 | import sys 6 | 7 | guides = "kdenlive:docproperties.guides" 8 | framerate = 30 9 | 10 | def find_mainbin(root): 11 | for child in root: 12 | if "id" in child.attrib and child.attrib["id"] == "main_bin": 13 | return child 14 | 15 | def find_guides(root): 16 | for child in root: 17 | if "name" in child.attrib and child.attrib["name"] == guides: 18 | return child.text 19 | 20 | def parse_guides(guides): 21 | for guide in guides: 22 | print(time.strftime('%-M:%S', time.gmtime(guide["pos"]/framerate)), guide["comment"]) 23 | 24 | if len(sys.argv) == 2: 25 | tree = ET.parse(sys.argv[1]) 26 | main_bin = find_mainbin(tree.getroot()) 27 | guides = json.loads(find_guides(main_bin)) 28 | parse_guides(guides) 29 | else: 30 | print("No File") 31 | -------------------------------------------------------------------------------- /toggleprogram: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Toggles a problem on and off 3 | 4 | ID=$(pgrep "$1") 5 | 6 | if [ -z "$ID" ]; then 7 | "$1" "$2" 8 | else 9 | killandnotify "$1" "$1 killed" 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /toggletouch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to toggle my laptops touchpad 3 | id="$(xinput list | grep -Eo 'Touchpad.*id=[0-9]*' | grep -Eo '[0-9]*')" 4 | mode="$(echo "$id" | xargs -I % xinput --list-props % | grep 'Device Enabled' | grep -Eo ':.*[0|1]' | grep -Eo '[0|1]')" 5 | 6 | if [ "$mode" -eq "1" ]; then 7 | xinput set-prop "$id" "Device Enabled" 0 && notify-send "Touchpad" "Touchpad has been disabled" 8 | else 9 | xinput set-prop "$id" "Device Enabled" 1 && notify-send "Touchpad" "Touchpad has been enabled" 10 | fi 11 | -------------------------------------------------------------------------------- /torque: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Torque - minimal tui for transmission-daemon. 4 | 5 | refresh() { 6 | printf '\e[?7l\e[?25l\e[2J\e[H' 7 | shopt -s checkwinsize; (:;:) 8 | [[ -z "$LINES" ]] && read -r LINES COLUMNS < <(stty size) 9 | ((j=(LINES-2)/3)) 10 | } 11 | 12 | status() { 13 | printf '\e[2m\e[%s;H%s\e[m' "$((LINES-1))" "$1" 14 | } 15 | 16 | get_torrents() { 17 | IFS=$'\n' read -d "" -ra t < <(transmission-remote -l) 18 | unset 't[0]' 't[-1]' 2>/dev/null 19 | 20 | t=("${t[@]//[0-9] [a-z][a-z][a-z]?/.}") 21 | t=("${t[@]//Up & Down/Active}") 22 | t=("${t[@]//Downloading/Active}") 23 | t=("${t[@]// None/0 MB}") 24 | 25 | for((i=${k:=0};i<(j=j>${#t[@]}?${#t[@]}:j);i++));{ t_print "${t[i]/n\/a/0}";} 26 | status "[s]tart [p]ause [r]emove [o]pen [j/k] [q]uit scroll ($j/${#t[@]})"$'\e[H' 27 | } 28 | 29 | t_print() { 30 | IFS=" %" read -r num perc have unit _ up down _ stat name <<< "$1" 31 | 32 | ((size=perc!=0?${have/.*}*100/perc:0,c=perc==100?33271340:31000000)) 33 | 34 | printf '\e[K\e[2m%s\e[m \e[1m\e[%s%b%s\e[m\n' \ 35 | "$num:" "${c:0:2}m" "\\u${c:2:4}\\${c:6}" "$name" 36 | printf '\e[K\e7%s\e8\e[14C%s\e8\e[32C%s\e8\e[42C%s\e8\e[52C%s\n\e[K\n' \ 37 | " $stat: " "$have / $size $unit" "(${perc}%)" "⇣ $down" "⇡ $up" 38 | } 39 | 40 | prompt() { 41 | send() { transmission-remote "$@" >/dev/null; } 42 | status $'\e[B\e[?25h' 43 | 44 | case "$1" in 45 | s) read -rp "start torrent: #"; send -t "$REPLY" -s ;; 46 | p) read -rp "pause torrent: #"; send -t "$REPLY" -S ;; 47 | r) read -rp "remove torrent: #"; send -t "$REPLY" -r; k=0 ;; 48 | o) read -rp "load magnet: "; send -a "$REPLY"; k=0 ;; 49 | j) ((j==${#t[@]}))||((k=k>=j?k:++k,j=j<${#t[@]}?++j:j)) ;; 50 | k) ((k==0))||((k=k<=j?k>0?--k:0:j,j=j>0?--j:j)) ;; 51 | q) exit 0 ;; 52 | esac 53 | 54 | [[ "$1" =~ (j|k) ]] || refresh && printf '\e[?25l\e[H' 55 | } 56 | 57 | main() { 58 | refresh 59 | 60 | trap $'printf \e[?25h\e[?7h\e[999B' EXIT 61 | trap 'refresh; k=0' SIGWINCH 62 | 63 | for ((;;)); { get_torrents; read -rsN1 -t1 && prompt "$REPLY"; } 64 | } 65 | 66 | main 67 | -------------------------------------------------------------------------------- /transmission/notifytorrents: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # A super hacky script to display the torrents in transmission in a notification 3 | torrents="$(transmission-remote -l | sed '/Sum/d')" 4 | notify-send "Torrents" "$(echo "$torrents" | sed '1d' | awk '{printf $2 " " $3 " " $4 " "}{for(i = 10; i < 30; i++) printf $i" "}{print ""}' | awk '{$1=$1};1')" 5 | 6 | # Updates the bar torrents module 7 | # if pgrep "polybar"; then 8 | # polybar-msg -p "$(pidof "polybar")" hook torrents 1 9 | # fi 10 | 11 | #awk '{print $2 "\t" $3 "\t"}{for(i = 9; i < 20; i++) printf $i}' 12 | #echo "$torrents" | sed '1d' | awk '{printf $2 "\t" $3}{for(i = 1; i < 10; i++) $i=""}{print}' 13 | -------------------------------------------------------------------------------- /transmission/tordone: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Sends a notification when a torrent is completed in transmission 3 | # Signals an update to the bar torrent module 4 | 5 | notify-send "Transmission-daemon" "$TR_TORRENT_NAME has completely downloaded" && polybar-msg hook torrents 1 #&& pkill -SIGRTMIN+2 i3blocks 6 | -------------------------------------------------------------------------------- /transmission/transadd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Mime map script for adding a magnet link to transmission, and starts the daemon if it's not running 3 | # Sends a notification when a torrent is added to transmission 4 | 5 | pgrep -x transmission-daemon > /dev/null || transmission-daemon 6 | 7 | transmission-remote --add "$@" && notify-send "Transmission-daemon" "Torrent added." && polybar-msg hook torrents 1 #&& pkill -SIGRTMIN+2 i3blocks 8 | -------------------------------------------------------------------------------- /transmission/transclr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Clears out all completed torrents in transmission 3 | 4 | transmission-remote -l | awk '$2 == "100%"{ system("transmission-remote -t " $1 " --remove") }' && polybar-msg -p "$(pidof "polybar")" hook torrents 1 # && pkill -SIGRTMIN+2 i3blocks 5 | -------------------------------------------------------------------------------- /tuxtalk: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | query="$(echo "" | dmenu -n)" 3 | tuxi -r "$query" | espeak --stdout | paplay 4 | -------------------------------------------------------------------------------- /updatepackages: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Opens a terminal to update pacman packages and handle updating my i3block 3 | 4 | $TERMINAL -e sudo pacman -Su && polybar-msg -p "$(pidof "polybar")" hook pacman-packages 1 #&& pkill -SIGRTMIN+3 i3blocks 5 | -------------------------------------------------------------------------------- /updatesubs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | Main="$(curl -s https://www.youtube.com/channel/UCld68syR8Wi-GY_n4CaoJGA | grep -i "subscribers" | awk -F\> '{print $19}' | awk -F\< '{print $1}')" 4 | 5 | if [ ! -z "$Main" ]; then 6 | echo "$Main" > ~/.cache/subs/main 7 | fi 8 | 9 | Podcast="$(curl -s https://www.youtube.com/channel/UCBq5p-xOla8xhnrbhu8AIAg | grep -i "subscribers" | awk -F\> '{print $19}' | awk -F\< '{print $1}')" 10 | 11 | if [ ! -z "$Podcast" ]; then 12 | echo "$Podcast" > ~/.cache/subs/podcast 13 | fi 14 | -------------------------------------------------------------------------------- /videospace: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | awesome-client 'awful=require("awful"); 4 | awful.screen.focus(2) 5 | awful.screen.focused().tags[1]:view_only() 6 | awful.screen.focused().selected_tag.master_count = 2' 7 | 8 | case "$1" in 9 | "stream") 10 | brave & 11 | obs & 12 | $TERMINAL -e pulsemixer & 13 | $TERMINAL -e ncmpcpp & 14 | $TERMINAL --class="VimWiki,VimWiki" -e nvim $XDG_DATA_HOME/vimwiki/index.wiki & 15 | streamtime & 16 | songname & 17 | ;; 18 | "video") 19 | pcmanfm & 20 | obs & 21 | $TERMINAL -e pulsemixer & 22 | $TERMINAL --class="VimWiki,VimWiki" -e nvim $XDG_DATA_HOME/vimwiki/index.wiki & 23 | ;; 24 | esac 25 | -------------------------------------------------------------------------------- /view: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Open up files in a read only mode, only makes sense for files where this is applicable 3 | 4 | libre() { 5 | pdffile=$(echo "$1" | grep -o ".*\.")"pdf" 6 | libreoffice --convert-to pdf "$1" --headless >/dev/null 2>&1 && "$READER" "$pdffile" && rm "$pdffile" 7 | } 8 | case $1 in 9 | *.odt) libre "$1";; 10 | *.mkv|*.mp4) $VIDEO "$1";; 11 | *.png|*.jpg|*.jpeg) $IMAGE "$1";; 12 | *.pdf) $READER "$1";; 13 | *) less "$1" ;; 14 | esac 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /virmon: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Testing out virtual monitors 3 | if [ -z "$(xrandr --listactivemonitors | grep 'eDP-1~1')" ]; then 4 | xrandr --setmonitor eDP-1~1 960/154x1080/173+0+0 eDP-1 5 | xrandr --setmonitor eDP-1~2 960/155x1080/173+960+0 none 6 | xrandr --fb 1920x1080 7 | else 8 | xrandr --delmonitor eDP-1~1 9 | xrandr --delmonitor eDP-1~2 10 | fi 11 | 12 | --------------------------------------------------------------------------------