diff --git a/.config/i3blocks/LICENSE.md b/.config/i3blocks/LICENSE.md new file mode 100644 index 0000000..324f7cf --- /dev/null +++ b/.config/i3blocks/LICENSE.md @@ -0,0 +1,692 @@ +This project is a repository project composed of many individual blocklet +projects. As such, we empower developers to license their blocklet source as +they see fit with one major caveat. This repository servers as the single +packaging source for most OS distributions. As such, we insist that any license +you choose meet both the +[Debian](http://www.debian.org/social_contract#guidelines) and +[Fedora](https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#License_of_Fedora_SPEC_Files) +free license specifications. For a handy chart, see +[Wikipedia](https://en.wikipedia.org/wiki/Comparison_of_free_and_open-source_software_licenses#Approvals). + +All blocklets are licensed individually. Consult the `LICENSE.md` contained +within each blocklet's directory for the licencing under which the contained +blocklet code is published. All blocklets without a `LICENSE.md` in their +directory, and all code within the parent of this repository are published +under the following license. + +``` + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. +``` diff --git a/.config/i3blocks/README.adoc b/.config/i3blocks/README.adoc new file mode 100644 index 0000000..907937c --- /dev/null +++ b/.config/i3blocks/README.adoc @@ -0,0 +1,73 @@ += Community contributed blocklets + +This repository contains a set of scripts (a.k.a. *blocklets*) for link:https://github.com/vivien/i3blocks[i3blocks], contributed by the community. + +|=== +| Blocklet | Description +| link:afs[] | Show usage information for an AFS directory +| link:apt-upgrades[] | Show system upgrades using aptitude +| link:arch-update[] | Show AUR updates using yaourt +| link:aur-update[] | Show AUR updates +| link:bandwidth[] | Show bandwidth information (default bash version) +| link:bandwidth2[] | Show bandwidth information (C version) +| link:bandwidth3[] | Show bandwidth information (another bash version) +| link:battery[] | Show battery info +| link:battery2[] | Pretty battery info +| link:batterybar[] | Show battery info graphically as a bar +| link:calendar[] | Current date/time and click for calendar +| link:cpu_usage[] | Show current CPU usage +| link:cpu_usage2[] | Show current CPU usage (C version) +| link:disk[] | Show disk usage (space used) for a given directory +| link:disk-io[] | Monitor disk reads and writes +| link:docker[] | Show the number of Docker containers and container IP +| link:email[] | Show the number of unread IMAP messages +| link:essid[] | Show the wifi ESSID you are connected to +| link:gpu-load[] | Shows load of Nvidia GPUs +| link:iface[] | Show network interface IP/status +| link:kbdd_layout[] | Show the keyboard layout using dbus and kbdd +| link:keyindicator[] | Show the status of capslock or numlock +| link:key_layout[] | Show the current keyboard layout using setxkbmap +| link:kubernetes[] | Show the kubernetes current context and namespace +| link:load_average[] | Show the system 1 minute load average +| link:mediaplayer[] | Generic media player status/controls using playerctl +| link:memory[] | Show ram or swap usage +| link:monitor_manager[] | Manage monitor on/off, resolution, extend, clone +| link:nm-vpn[] | Show vpn status using network manager +| link:openvpn[] | Show openvpn status +| link:rofi-calendar[] | Current date/time and click for callendar using rofi +| link:shutdown_menu[] | Shutdown menu using rofi or zenity +| link:tahoe-lafs[] | Show status of your tahoe-lafs grid +| link:temperature[] | Show system temperatures using lm-sensors +| link:time[] | Show the current date/time and click to change timezones +| link:usb[] | Show connected usb storage device info +| link:volume[] | Show the current system volume (default) +| link:volume-pulseaudio[] | Pretty print system volume for pulseaudio +| link:wifi[] | Show the strength of your wifi connection in percent +| link:wlan-dbm[] | Show wifi interface link quality in dBm or percent +| link:ytdl-mpv[] | Play youtube videos from your clipboard using youtube-dl +|=== + +It is officially maintained by @kb100 with the help of a bench of active i3blocks crafters. + +Each release of this repository will be guaranteed to work against a given link:https://github.com/vivien/i3blocks/releases[release] of i3blocks (a.k.a. *core*). + +|=== +| contrib | core +| master | master +| next | next +|=== + +You may want to take a look at the individual blocklet directories, which contain descriptions, screenshots, and installation/configuration instructions. + +NOTE: configurations reference `$SCRIPT_DIR`, meaning the directory that you put the script into. + +You must change `$SCRIPT_DIR` appropriately to coincide with where you put your scripts, for more info see the link:https://github.com/vivien/i3blocks-contrib/wiki/FAQ#blocklets-refer-to-script_dir-what-does-that-mean-how-can-i-use-it[FAQ]. + +Want to contribute? +Great! +Check the link:https://github.com/vivien/i3blocks-contrib/blob/master/CONTRIBUTING.md[contribution guidelines] in order to get started. + +NOTE: i3blocks now supports dynamics properties, and all scripts have been updated to do the same. + +i3blocks-contrib REQUIRES a version of i3blocks that supports dynamics properties, which is currently only + +available in the git version since the last release (v1.4) was years ago. + +Happy crafting! diff --git a/.config/i3blocks/afs/LICENSE.md b/.config/i3blocks/afs/LICENSE.md new file mode 100644 index 0000000..5f8b06f --- /dev/null +++ b/.config/i3blocks/afs/LICENSE.md @@ -0,0 +1,675 @@ +### GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. + + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +### Preamble + +The GNU General Public License is a free, copyleft license for +software and other kinds of works. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom +to share and change all versions of a program--to make sure it remains +free software for all its users. We, the Free Software Foundation, use +the GNU General Public License for most of our software; it applies +also to any other work released this way by its authors. You can apply +it to your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you +have certain responsibilities if you distribute copies of the +software, or if you modify it: responsibilities to respect the freedom +of others. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + +Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + +Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the +manufacturer can do so. This is fundamentally incompatible with the +aim of protecting users' freedom to change the software. The +systematic pattern of such abuse occurs in the area of products for +individuals to use, which is precisely where it is most unacceptable. +Therefore, we have designed this version of the GPL to prohibit the +practice for those products. If such problems arise substantially in +other domains, we stand ready to extend this provision to those +domains in future versions of the GPL, as needed to protect the +freedom of users. + +Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish +to avoid the special danger that patents applied to a free program +could make it effectively proprietary. To prevent this, the GPL +assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and +modification follow. + +### TERMS AND CONDITIONS + +#### 0. Definitions. + +"This License" refers to version 3 of the GNU General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds +of works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of +an exact copy. The resulting work is called a "modified version" of +the earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based +on the Program. + +To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user +through a computer network, with no transfer of a copy, is not +conveying. + +An interactive user interface displays "Appropriate Legal Notices" to +the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +#### 1. Source Code. + +The "source code" for a work means the preferred form of the work for +making modifications to it. "Object code" means any non-source form of +a work. + +A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can +regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same +work. + +#### 2. Basic Permissions. + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, +without conditions so long as your license otherwise remains in force. +You may convey covered works to others for the sole purpose of having +them make modifications exclusively for you, or provide you with +facilities for running those works, provided that you comply with the +terms of this License in conveying all material for which you do not +control copyright. Those thus making or running the covered works for +you must do so exclusively on your behalf, under your direction and +control, on terms that prohibit them from making any copies of your +copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the +conditions stated below. Sublicensing is not allowed; section 10 makes +it unnecessary. + +#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such +circumvention is effected by exercising rights under this License with +respect to the covered work, and you disclaim any intention to limit +operation or modification of the work as a means of enforcing, against +the work's users, your or third parties' legal rights to forbid +circumvention of technological measures. + +#### 4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + +#### 5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these +conditions: + +- a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. +- b) The work must carry prominent notices stating that it is + released under this License and any conditions added under + section 7. This requirement modifies the requirement in section 4 + to "keep intact all notices". +- c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. +- d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + +#### 6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms of +sections 4 and 5, provided that you also convey the machine-readable +Corresponding Source under the terms of this License, in one of these +ways: + +- a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. +- b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the Corresponding + Source from a network server at no charge. +- c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. +- d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. +- e) Convey the object code using peer-to-peer transmission, + provided you inform other peers where the object code and + Corresponding Source of the work are being offered to the general + public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, +family, or household purposes, or (2) anything designed or sold for +incorporation into a dwelling. In determining whether a product is a +consumer product, doubtful cases shall be resolved in favor of +coverage. For a particular product received by a particular user, +"normally used" refers to a typical or common use of that class of +product, regardless of the status of the particular user or of the way +in which the particular user actually uses, or expects or is expected +to use, the product. A product is a consumer product regardless of +whether the product has substantial commercial, industrial or +non-consumer uses, unless such uses represent the only significant +mode of use of the product. + +"Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to +install and execute modified versions of a covered work in that User +Product from a modified version of its Corresponding Source. The +information must suffice to ensure that the continued functioning of +the modified object code is in no case prevented or interfered with +solely because modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or +updates for a work that has been modified or installed by the +recipient, or for the User Product in which it has been modified or +installed. Access to a network may be denied when the modification +itself materially and adversely affects the operation of the network +or violates the rules and protocols for communication across the +network. + +Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + +#### 7. Additional Terms. + +"Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders +of that material) supplement the terms of this License with terms: + +- a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or +- b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or +- c) Prohibiting misrepresentation of the origin of that material, + or requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or +- d) Limiting the use for publicity purposes of names of licensors + or authors of the material; or +- e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or +- f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions + of it) with contractual assumptions of liability to the recipient, + for any liability that these contractual assumptions directly + impose on those licensors and authors. + +All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; the +above requirements apply either way. + +#### 8. Termination. + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +#### 9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run +a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + +#### 10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + +#### 11. Patents. + +A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims owned +or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + +A patent license is "discriminatory" if it does not include within the +scope of its coverage, prohibits the exercise of, or is conditioned on +the non-exercise of one or more of the rights that are specifically +granted under this License. You may not convey a covered work if you +are a party to an arrangement with a third party that is in the +business of distributing software, under which you make payment to the +third party based on the extent of your activity of conveying the +work, and under which the third party grants, to any of the parties +who would receive the covered work from you, a discriminatory patent +license (a) in connection with copies of the covered work conveyed by +you (or copies made from those copies), or (b) primarily for and in +connection with specific products or compilations that contain the +covered work, unless you entered into that arrangement, or that patent +license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + +#### 12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under +this License and any other pertinent obligations, then as a +consequence you may not convey it at all. For example, if you agree to +terms that obligate you to collect a royalty for further conveying +from those to whom you convey the Program, the only way you could +satisfy both those terms and this License would be to refrain entirely +from conveying the Program. + +#### 13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + +#### 14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions +of the GNU General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in +detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies that a certain numbered version of the GNU General Public +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that numbered version or +of any later version published by the Free Software Foundation. If the +Program does not specify a version number of the GNU General Public +License, you may choose any version ever published by the Free +Software Foundation. + +If the Program specifies that a proxy can decide which future versions +of the GNU General Public License can be used, that proxy's public +statement of acceptance of a version permanently authorizes you to +choose that version for the Program. + +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + +#### 15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE +DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR +CORRECTION. + +#### 16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR +CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT +NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR +LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM +TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER +PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +#### 17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +### How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + +To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively state +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper +mail. + +If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands \`show w' and \`show c' should show the +appropriate parts of the General Public License. Of course, your +program's commands might be different; for a GUI interface, you would +use an "about box". + +You should also get your employer (if you work as a programmer) or +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. For more information on this, and how to apply and follow +the GNU GPL, see . + +The GNU General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use the +GNU Lesser General Public License instead of this License. But first, +please read . diff --git a/.config/i3blocks/afs/README.md b/.config/i3blocks/afs/README.md new file mode 100644 index 0000000..86a6065 --- /dev/null +++ b/.config/i3blocks/afs/README.md @@ -0,0 +1,27 @@ +# afs + +Show usage information for an [AFS](https://en.wikipedia.org/wiki/Andrew_File_System) directory. + +![](example.png) + +## Setup / Usage + +Suggested i3blocks configuration: + +``` +[afs] +command=$SCRIPT_DIR/afs +instance=~/afs/ +markup=pango +interval=600 +LABEL=AFS +#CRITICAL=90 +#CRIT_FG_COLOR=#FF0000 +#CRIT_BG_COLOR= +``` + +## Dependencies + +- `fs` command suite shipped with the AFS client software +- python3 + diff --git a/.config/i3blocks/afs/afs b/.config/i3blocks/afs/afs new file mode 100755 index 0000000..8d61967 --- /dev/null +++ b/.config/i3blocks/afs/afs @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +# Show usage information for an AFS directory. + +# Copyright 2017 Johannes Lange +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import argparse +import os +import subprocess as sp + +def _default(name, default='', arg_type=str): + val = default + if name in os.environ: + val = os.environ[name] + return arg_type(val) + +parser = argparse.ArgumentParser( + description='Get AFS quota and usage information.', + formatter_class=argparse.ArgumentDefaultsHelpFormatter, +) +parser.add_argument('-c', '--critical', type=int, default=_default('CRITICAL', 90, int), + help='Critical usage percentage.') +parser.add_argument('-fg', '--fg-color', type=str, default=_default('CRIT_FG_COLOR', "#FF0000"), + help='Foreground color for critical usage.') +parser.add_argument('-bg', '--bg-color', type=str, default=_default('CRIT_BG_COLOR', ''), + help='Background color for critical usage.') +args = parser.parse_args() + +# set the afs directory to be checked +directory = os.environ.get('BLOCK_INSTANCE', '~/afs/') +label = os.environ.get('LABEL', '') + +# expand environment variables etc. +directory = os.path.expandvars(directory) +directory = os.path.expanduser(directory) + +fs_output = sp.check_output(['fs', 'lq', '-human', directory], + universal_newlines=True) + +# second line contains the information +fs_output = fs_output.split('\n')[1] +quota, used, percentage = fs_output.split()[1:4] +percentage = int(percentage.split('%')[0]) + +output = '%s%s/%s (%i%%)' % (label, used, quota, percentage) + +if percentage >= args.critical: + if args.bg_color: + output = "%s" %\ + (args.fg_color, args.bg_color, output) + else: + output = "%s" % (args.fg_color, output) + +print(output) diff --git a/.config/i3blocks/afs/example.png b/.config/i3blocks/afs/example.png new file mode 100644 index 0000000..23d82f0 Binary files /dev/null and b/.config/i3blocks/afs/example.png differ diff --git a/.config/i3blocks/apt-upgrades/LICENSE b/.config/i3blocks/apt-upgrades/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/apt-upgrades/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/apt-upgrades/README.md b/.config/i3blocks/apt-upgrades/README.md new file mode 100644 index 0000000..7919d2a --- /dev/null +++ b/.config/i3blocks/apt-upgrades/README.md @@ -0,0 +1,56 @@ +# apt-upgrades + +Show the number of pending system upgrades, as reported by aptitude. +More specifically, show: packages upgraded, newly installed, to remove, and not upgraded. + + +![](apt-upgrades.png) + +# Requirements + +Dependencies: aptitude, bash + +Suggested: fonts-font-awesome + +# Suggested usage + +Copy the `i3blocks.conf` section into your i3blocks configuration. +We assume you use `signal=1` but you can choose another signal number if you prefer. +Create apt/dpkg hooks to signal the script. +For example, create `/etc/apt/apt.conf.d/80i3blocks` with contents + +``` +APT::Update::Post-Invoke { "pkill -RTMIN+1 i3blocks || true"; }; +DPkg::Post-Invoke { "pkill -RTMIN+1 i3blocks || true"; }; +``` +**Warning**: make sure to +```ShellSession +sudo chown root:root /etc/apt/apt.conf.d/80i3blocks +sudo chmod 644 /etc/apt/apt.conf.d/80i3blocks +``` +so that only the root user may modify +`80i3blocks`. This is necessary because apt has root privileges when upgrading the system, +and therefore commands in `80i3blocks` will be executed with root privileges. + +You may also combine this script with a cron job that calls `apt-get update` periodically for +a more "popup upgrade reminder" feeling. + +# Simple usage + +Instead of using `signal=1` in the configuration, you can use `interval=3600` +to have the script execute every hour. +This method avoids the usage of apt/dpkg hooks. + +# Config + +```INI +[apt-upgrades] +command=$SCRIPT_DIR/apt-upgrades +signal=1 +interval=once +#PENDING_SYMBOL="\uf021 " +#SYMBOL_ONLY=0 +#ALWAYS_PRINT=1 +#PENDING_COLOR="#00FF00" +#NONPENDING_COLOR="#FFFFFF" +``` diff --git a/.config/i3blocks/apt-upgrades/apt-upgrades b/.config/i3blocks/apt-upgrades/apt-upgrades new file mode 100755 index 0000000..116edcc --- /dev/null +++ b/.config/i3blocks/apt-upgrades/apt-upgrades @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2015 James Murphy +# Licensed under the terms of the GNU GPL v2 only. +# +# i3blocks blocklet script to display pending system upgrades + +# FontAwesome refresh symbol, change if you do not want to install FontAwesome +PENDING_SYMBOL=${PENDING_SYMBOL:-"\uf021 "} + +# By default, show both the symbol and the numbers +SYMBOL_ONLY=${SYMBOL_ONLY:-0} + +# By default, show something when no upgrades are pending +ALWAYS_PRINT=${ALWAYS_PRINT:-1} + +# Colors for when there is/isn't a pending upgrade +PENDING_COLOR=${PENDING_COLOR:-"#00FF00"} +NONPENDING_COLOR=${NONPENDING_COLOR:-"#FFFFFF"} + +while getopts s:oc:n:Nh opt; do + case "$opt" in + s) PENDING_SYMBOL="$OPTARG" ;; + o) SYMBOL_ONLY=1 ;; + c) PENDING_COLOR="$OPTARG" ;; + n) NONPENDING_COLOR="$OPTARG" ;; + N) ALWAYS_PRINT=0 ;; + h) printf \ +"Usage: apt-upgrades [-s pending_symbol] [-o] [-c pending_color] [-N|-n nonpending_color] [-h] +Options: +-s\tSpecify a refresh symbol. Default: \"\\\\uf021 \" +-o\tShow refresh symbol only, but no numbers. +-c\tColor when upgrade is pending. Default: #00FF00 +-n\tColor when no upgrade is pending. Default: #FFFFFF +-N\tOnly display text if upgrade is pending (supercedes -n) +-h\tShow this help text\n" && exit 0;; + esac +done + +read upgraded new removed held < <( +aptitude full-upgrade --simulate --assume-yes |\ + grep -m1 '^[0-9]\+ packages upgraded,' |\ + tr -cd '0-9 ' |\ + tr ' ' '\n' |\ + grep '[0-9]\+' |\ + xargs echo) + +if [[ $upgraded != 0 ]] || [[ $new != 0 ]] || [[ $removed != 0 ]] || [[ $held != 0 ]]; then + color="$PENDING_COLOR" + if [[ $SYMBOL_ONLY == 1 ]]; then + echo -e "$PENDING_SYMBOL" + echo -e "$PENDING_SYMBOL" + else + echo -e "$PENDING_SYMBOL$upgraded/$new/$removed/$held" + echo -e "$PENDING_SYMBOL$upgraded/$new/$removed/$held" + fi + echo $color +elif [[ $ALWAYS_PRINT == 1 ]]; then + color="$NONPENDING_COLOR" + echo -e "$PENDING_SYMBOL$upgraded/$new/$removed/$held" + echo -e "$PENDING_SYMBOL$upgraded/$new/$removed/$held" + echo $color +fi + diff --git a/.config/i3blocks/apt-upgrades/apt-upgrades.png b/.config/i3blocks/apt-upgrades/apt-upgrades.png new file mode 100644 index 0000000..df28339 Binary files /dev/null and b/.config/i3blocks/apt-upgrades/apt-upgrades.png differ diff --git a/.config/i3blocks/apt-upgrades/i3blocks.conf b/.config/i3blocks/apt-upgrades/i3blocks.conf new file mode 100644 index 0000000..4eb926e --- /dev/null +++ b/.config/i3blocks/apt-upgrades/i3blocks.conf @@ -0,0 +1,4 @@ +[apt-upgrades] +command=$SCRIPT_DIR/apt-upgrades +signal=1 +interval=once diff --git a/.config/i3blocks/arch-update/LICENSE.md b/.config/i3blocks/arch-update/LICENSE.md new file mode 100644 index 0000000..660ee4e --- /dev/null +++ b/.config/i3blocks/arch-update/LICENSE.md @@ -0,0 +1,225 @@ +GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. http://fsf.org/ + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. +Preamble + +The GNU General Public License is a free, copyleft license for software and other kinds of works. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. +TERMS AND CONDITIONS +0. Definitions. + +"This License" refers to version 3 of the GNU General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based on the Program. + +To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. +1. Source Code. + +The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. + +A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. +2. Basic Permissions. + +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. +3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. +4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. +5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. +6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. +7. Additional Terms. + +"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. +8. Termination. + +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. +9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. +10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. +11. Patents. + +A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. +12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. +13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. +14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. +15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". + +You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see http://www.gnu.org/licenses/. + +The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read http://www.gnu.org/philosophy/why-not-lgpl.html. diff --git a/.config/i3blocks/arch-update/README.md b/.config/i3blocks/arch-update/README.md new file mode 100644 index 0000000..34232af --- /dev/null +++ b/.config/i3blocks/arch-update/README.md @@ -0,0 +1,54 @@ +# arch-update + +Be always on top of your available updates with this blocklet. Optionally show AUR updates with the help of yaourt. Colorize the outputs for if your system is up to date or you got available updates. + +![](screenshot.png) + +![](screenshot2.png) + +# Dependencies + +* Arch Linux or another arch based distro +* python3 +* [pacman-contrib](https://www.archlinux.org/packages/?name=pacman-contrib) for `checkupdates` + +# Optional Dependencies + +* yaourt for aur updates +* fontawesome for awesome labels + +# Installation + +* Copy the arch-update script into your directory of choice, e.g. ~/.i3blocks/ +* Give it execution permission (`chmod +x arch-update`) +* Add the following blocket to your i3blocks.conf: + +```ini +[arch-update] +command=$SCRIPT_DIR/arch-update +interval=3600 +markup=pango +LABEL=Updates: +``` +Another advanced example with fontawesome label, AUR updates included, watched packages, and custom colors for both messages: +```ini +[pacman-updates] +command=$SCRIPT_DIR/arch-update +markup=pango +interval= 3600 +QUIET=true +WATCH=^linux.* ^pacman.* +BASE_COLOR=#5fff5f +UPDATE_COLOR=#FFFF85 +AUR=true +LABEL= +``` +# Configuration +_Use the environment variables above instead of these deprecated command line options:_ + +- `-q`/`--quiet`: do not produce output if system is up to date +- `-w`/`--watch`: Explicitly watch for specified packages. Listed elements are treated as regular expressions for matching. +- `-b`/`--base_color`: set the base color of the output (when your system is up to date) +- `-u`/`--updates_available_color`: set the color of the output when updates are available +- `-a`/`--aur`: activate AUR update support +For the latest options call `$SCRIPT_DIR/arch-update -h`. diff --git a/.config/i3blocks/arch-update/arch-update b/.config/i3blocks/arch-update/arch-update new file mode 100755 index 0000000..59044ed --- /dev/null +++ b/.config/i3blocks/arch-update/arch-update @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2017 Marcel Patzwahl +# Licensed under the terms of the GNU GPL v3 only. +# +# i3blocks blocklet script to see the available updates of pacman and the AUR +import subprocess +from subprocess import check_output +import argparse +import os +import re + + +def create_argparse(): + def _default(name, default='', arg_type=str): + val = default + if name in os.environ: + val = os.environ[name] + return arg_type(val) + + strbool = lambda s: s.lower() in ['t', 'true', '1'] + strlist = lambda s: s.split() + + parser = argparse.ArgumentParser(description='Check for pacman updates') + parser.add_argument( + '-b', + '--base_color', + default = _default('BASE_COLOR', 'green'), + help='base color of the output(default=green)' + ) + parser.add_argument( + '-u', + '--updates_available_color', + default = _default('UPDATE_COLOR', 'yellow'), + help='color of the output, when updates are available(default=yellow)' + ) + parser.add_argument( + '-a', + '--aur', + action = 'store_const', + const = True, + default = _default('AUR', 'False', strbool), + help='Include AUR packages. Attn: Yaourt must be installed' + ) + parser.add_argument( + '-q', + '--quiet', + action = 'store_const', + const = True, + default = _default('QUIET', 'False', strbool), + help = 'Do not produce output when system is up to date' + ) + parser.add_argument( + '-w', + '--watch', + nargs='*', + default = _default('WATCH', arg_type=strlist), + help='Explicitly watch for specified packages. ' + 'Listed elements are treated as regular expressions for matching.' + ) + return parser.parse_args() + + +def get_updates(): + output = check_output(['checkupdates']).decode('utf-8') + if not output: + return [] + + updates = [line.split(' ')[0] + for line in output.split('\n') + if line] + + return updates + + +def get_aur_updates(): + output = '' + try: + output = check_output(['yaourt', '-Qua']).decode('utf-8') + except subprocess.CalledProcessError as exc: + # yaourt exits with 1 and no output if no updates are available. + # we ignore this case and go on + if not (exc.returncode == 1 and not exc.output): + raise exc + if not output: + return [] + + aur_updates = [line.split(' ')[0] + for line in output.split('\n') + if line.startswith('aur/')] + + return aur_updates + + +def matching_updates(updates, watch_list): + matches = set() + for u in updates: + for w in watch_list: + if re.match(w, u): + matches.add(u) + + return matches + + +label = os.environ.get("LABEL","") +message = "{0}{2}" +args = create_argparse() + +updates = get_updates() +if args.aur: + updates += get_aur_updates() + +update_count = len(updates) +if update_count > 0: + info = str(update_count) + ' updates available' + short_info = str(update_count) + ' updates' + matches = matching_updates(updates, args.watch) + if matches: + info += ' [{0}]'.format(', '.join(matches)) + short_info += '*' + print(message.format(label, args.updates_available_color, info)) + print(message.format(label, args.updates_available_color, short_info)) +elif not args.quiet: + print(message.format(label, args.base_color, 'system up to date')) diff --git a/.config/i3blocks/arch-update/arch-update.py b/.config/i3blocks/arch-update/arch-update.py new file mode 120000 index 0000000..fa3a47c --- /dev/null +++ b/.config/i3blocks/arch-update/arch-update.py @@ -0,0 +1 @@ +./arch-update \ No newline at end of file diff --git a/.config/i3blocks/arch-update/screenshot.png b/.config/i3blocks/arch-update/screenshot.png new file mode 100644 index 0000000..e4de85d Binary files /dev/null and b/.config/i3blocks/arch-update/screenshot.png differ diff --git a/.config/i3blocks/arch-update/screenshot2.png b/.config/i3blocks/arch-update/screenshot2.png new file mode 100644 index 0000000..0942798 Binary files /dev/null and b/.config/i3blocks/arch-update/screenshot2.png differ diff --git a/.config/i3blocks/aur-update/LICENSE.md b/.config/i3blocks/aur-update/LICENSE.md new file mode 100644 index 0000000..5f8b06f --- /dev/null +++ b/.config/i3blocks/aur-update/LICENSE.md @@ -0,0 +1,675 @@ +### GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. + + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +### Preamble + +The GNU General Public License is a free, copyleft license for +software and other kinds of works. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom +to share and change all versions of a program--to make sure it remains +free software for all its users. We, the Free Software Foundation, use +the GNU General Public License for most of our software; it applies +also to any other work released this way by its authors. You can apply +it to your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you +have certain responsibilities if you distribute copies of the +software, or if you modify it: responsibilities to respect the freedom +of others. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + +Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + +Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the +manufacturer can do so. This is fundamentally incompatible with the +aim of protecting users' freedom to change the software. The +systematic pattern of such abuse occurs in the area of products for +individuals to use, which is precisely where it is most unacceptable. +Therefore, we have designed this version of the GPL to prohibit the +practice for those products. If such problems arise substantially in +other domains, we stand ready to extend this provision to those +domains in future versions of the GPL, as needed to protect the +freedom of users. + +Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish +to avoid the special danger that patents applied to a free program +could make it effectively proprietary. To prevent this, the GPL +assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and +modification follow. + +### TERMS AND CONDITIONS + +#### 0. Definitions. + +"This License" refers to version 3 of the GNU General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds +of works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of +an exact copy. The resulting work is called a "modified version" of +the earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based +on the Program. + +To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user +through a computer network, with no transfer of a copy, is not +conveying. + +An interactive user interface displays "Appropriate Legal Notices" to +the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +#### 1. Source Code. + +The "source code" for a work means the preferred form of the work for +making modifications to it. "Object code" means any non-source form of +a work. + +A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can +regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same +work. + +#### 2. Basic Permissions. + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, +without conditions so long as your license otherwise remains in force. +You may convey covered works to others for the sole purpose of having +them make modifications exclusively for you, or provide you with +facilities for running those works, provided that you comply with the +terms of this License in conveying all material for which you do not +control copyright. Those thus making or running the covered works for +you must do so exclusively on your behalf, under your direction and +control, on terms that prohibit them from making any copies of your +copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the +conditions stated below. Sublicensing is not allowed; section 10 makes +it unnecessary. + +#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such +circumvention is effected by exercising rights under this License with +respect to the covered work, and you disclaim any intention to limit +operation or modification of the work as a means of enforcing, against +the work's users, your or third parties' legal rights to forbid +circumvention of technological measures. + +#### 4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + +#### 5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these +conditions: + +- a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. +- b) The work must carry prominent notices stating that it is + released under this License and any conditions added under + section 7. This requirement modifies the requirement in section 4 + to "keep intact all notices". +- c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. +- d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + +#### 6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms of +sections 4 and 5, provided that you also convey the machine-readable +Corresponding Source under the terms of this License, in one of these +ways: + +- a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. +- b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the Corresponding + Source from a network server at no charge. +- c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. +- d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. +- e) Convey the object code using peer-to-peer transmission, + provided you inform other peers where the object code and + Corresponding Source of the work are being offered to the general + public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, +family, or household purposes, or (2) anything designed or sold for +incorporation into a dwelling. In determining whether a product is a +consumer product, doubtful cases shall be resolved in favor of +coverage. For a particular product received by a particular user, +"normally used" refers to a typical or common use of that class of +product, regardless of the status of the particular user or of the way +in which the particular user actually uses, or expects or is expected +to use, the product. A product is a consumer product regardless of +whether the product has substantial commercial, industrial or +non-consumer uses, unless such uses represent the only significant +mode of use of the product. + +"Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to +install and execute modified versions of a covered work in that User +Product from a modified version of its Corresponding Source. The +information must suffice to ensure that the continued functioning of +the modified object code is in no case prevented or interfered with +solely because modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or +updates for a work that has been modified or installed by the +recipient, or for the User Product in which it has been modified or +installed. Access to a network may be denied when the modification +itself materially and adversely affects the operation of the network +or violates the rules and protocols for communication across the +network. + +Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + +#### 7. Additional Terms. + +"Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders +of that material) supplement the terms of this License with terms: + +- a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or +- b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or +- c) Prohibiting misrepresentation of the origin of that material, + or requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or +- d) Limiting the use for publicity purposes of names of licensors + or authors of the material; or +- e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or +- f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions + of it) with contractual assumptions of liability to the recipient, + for any liability that these contractual assumptions directly + impose on those licensors and authors. + +All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; the +above requirements apply either way. + +#### 8. Termination. + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +#### 9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run +a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + +#### 10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + +#### 11. Patents. + +A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims owned +or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + +A patent license is "discriminatory" if it does not include within the +scope of its coverage, prohibits the exercise of, or is conditioned on +the non-exercise of one or more of the rights that are specifically +granted under this License. You may not convey a covered work if you +are a party to an arrangement with a third party that is in the +business of distributing software, under which you make payment to the +third party based on the extent of your activity of conveying the +work, and under which the third party grants, to any of the parties +who would receive the covered work from you, a discriminatory patent +license (a) in connection with copies of the covered work conveyed by +you (or copies made from those copies), or (b) primarily for and in +connection with specific products or compilations that contain the +covered work, unless you entered into that arrangement, or that patent +license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + +#### 12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under +this License and any other pertinent obligations, then as a +consequence you may not convey it at all. For example, if you agree to +terms that obligate you to collect a royalty for further conveying +from those to whom you convey the Program, the only way you could +satisfy both those terms and this License would be to refrain entirely +from conveying the Program. + +#### 13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + +#### 14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions +of the GNU General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in +detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies that a certain numbered version of the GNU General Public +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that numbered version or +of any later version published by the Free Software Foundation. If the +Program does not specify a version number of the GNU General Public +License, you may choose any version ever published by the Free +Software Foundation. + +If the Program specifies that a proxy can decide which future versions +of the GNU General Public License can be used, that proxy's public +statement of acceptance of a version permanently authorizes you to +choose that version for the Program. + +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + +#### 15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE +DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR +CORRECTION. + +#### 16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR +CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT +NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR +LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM +TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER +PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +#### 17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +### How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + +To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively state +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper +mail. + +If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands \`show w' and \`show c' should show the +appropriate parts of the General Public License. Of course, your +program's commands might be different; for a GUI interface, you would +use an "about box". + +You should also get your employer (if you work as a programmer) or +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. For more information on this, and how to apply and follow +the GNU GPL, see . + +The GNU General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use the +GNU Lesser General Public License instead of this License. But first, +please read . diff --git a/.config/i3blocks/aur-update/README.md b/.config/i3blocks/aur-update/README.md new file mode 100644 index 0000000..7124dd7 --- /dev/null +++ b/.config/i3blocks/aur-update/README.md @@ -0,0 +1,29 @@ +# aur-update + +List available updates from the Arch User Repository (AUR) + +![](example.png) + +## Setup / Usage + +Example i3blocks configuration: + +``` +[aur-update] +command=$SCRIPT_DIR/aur-update +markup=pango +interval=43200 +UPDATE_COLOR=red +QUIET=1 +IGNORE=root vidyodesktop +``` + +Right or middle click sends a notification (via notify-send) with a list of outdated packages +and the corresponding version information. + + +## Dependencies + +- python3 [requests library](http://docs.python-requests.org/en/master/) +- optional: libnotify/notify-send + diff --git a/.config/i3blocks/aur-update/aur-update b/.config/i3blocks/aur-update/aur-update new file mode 100755 index 0000000..eb22ef0 --- /dev/null +++ b/.config/i3blocks/aur-update/aur-update @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 + +# List available updates from the Arch User Repository (AUR) + +# Copyright 2018 Johannes Lange +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import requests +import subprocess as sp + +block_button = os.environ['BLOCK_BUTTON'] if 'BLOCK_BUTTON' in os.environ else None +block_button = int(block_button) if block_button else None + + +class Args(object): + def add_argument(self, name, default='', arg_type=str): + val = default + if name in os.environ: + val = os.environ[name] + if arg_type == list: + val = val.split() + val = arg_type(val) + setattr(self, name.lower(), val) + return val + + +args = Args() +args.add_argument('UPDATE_COLOR', 'yellow') +args.add_argument('QUIET', False, bool) +args.add_argument('IGNORE', [], list) + + +def version_in_aur(pkg): + p = {'v': '5', 'type': 'search', 'by': 'name', 'arg': pkg} + response = requests.get('https://aur.archlinux.org/rpc/', params=p) + response = response.json() + for r in response['results']: + if r['Name'] == pkg: + return r['Version'] + + return "NotFound" + + +def vcs_version(pkg, ver): + """ Try to find a sensble version for VSC packages + + If pkg looks like a VCS package according to + https://wiki.archlinux.org/index.php/VCS_package_guidelines + try to extract a sensible (= comparable) version number. + """ + + suffices = ['-cvs', '-svn', '-hg', '-darcs', '-bzr', '-git'] + if not any(pkg.endswith(suffix) for suffix in suffices): + # does not look like a VCS package + return ver + + if '.r' in ver: + # of the form RELEASE.rREVISION: only use the release + return ver.split('.r')[0] + # no base release to compare, just return None + return None + + +# get list of foreign packages -- assumed to be from the AUR +packages = sp.check_output(['pacman', '-Qm']).decode('utf8') + +installed_version = {} +for pkg in packages.split('\n'): + if not pkg: + continue + pkg, ver = pkg.split() + installed_version[pkg] = ver + +updates = [] +for pkg in installed_version.keys(): + if pkg in args.ignore: + continue + v_aur = version_in_aur(pkg) + v_inst = installed_version[pkg] + if vcs_version(pkg, v_aur) != vcs_version(pkg, v_inst): + updates.append(pkg + ' (%s -> %s)' % (v_inst, v_aur)) + +n_updates = len(updates) +if n_updates > 0: + msg = "{1} AUR updates" + print(msg.format(args.update_color, n_updates)) +elif not args.quiet: + print('AUR up to date') + +if block_button in [2, 3]: + sp.call(['notify-send', 'AUR updates', '\n'.join(updates)]) + +if not 'BLOCK_NAME' in os.environ and n_updates > 0: + # not called by i3blocks: show the complete list + print('\n'.join(updates)) diff --git a/.config/i3blocks/aur-update/example.png b/.config/i3blocks/aur-update/example.png new file mode 100644 index 0000000..b7fbf86 Binary files /dev/null and b/.config/i3blocks/aur-update/example.png differ diff --git a/.config/i3blocks/bandwidth/README.md b/.config/i3blocks/bandwidth/README.md new file mode 100644 index 0000000..03872e1 --- /dev/null +++ b/.config/i3blocks/bandwidth/README.md @@ -0,0 +1,19 @@ +# bandwidth + +Show bandwidth information. Some interfaces report unknown instead of up for +their state. If you would like to treat unknowns as up, then set +`TREAT_UNKNOWN_AS_UP=1`. + +![](bandwidth.png) + +# Config + +``` +[bandwidth] +command=$SCRIPT_DIR/bandwidth +interval=5 +#INTERFACE=eth0 +#INLABEL=IN +#OUTLABEL=OUT +#TREAT_UNKNOWN_AS_UP=0 +``` diff --git a/.config/i3blocks/bandwidth/bandwidth b/.config/i3blocks/bandwidth/bandwidth new file mode 100755 index 0000000..6a93c35 --- /dev/null +++ b/.config/i3blocks/bandwidth/bandwidth @@ -0,0 +1,113 @@ +#!/bin/bash +# Copyright (C) 2012 Stefan Breunig +# Copyright (C) 2014 kaueraal +# Copyright (C) 2015 Thiago Perrotta + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Get custom IN and OUT labels if provided by command line arguments +while [[ $# -gt 1 ]]; do + key="$1" + case "$key" in + -i|--inlabel) + INLABEL="$2" + shift;; + -o|--outlabel) + OUTLABEL="$2" + shift;; + esac + shift +done + +[[ -z "$INLABEL" ]] && INLABEL="IN " +[[ -z "$OUTLABEL" ]] && OUTLABEL="OUT " + +# Use the provided interface, otherwise the device used for the default route. +if [[ -z $INTERFACE ]] && [[ -n $BLOCK_INSTANCE ]]; then + INTERFACE=$BLOCK_INSTANCE +elif [[ -z $INTERFACE ]]; then + INTERFACE=$(ip route | awk '/^default/ { print $5 ; exit }') +fi + +# Exit if there is no default route +[[ -z "$INTERFACE" ]] && exit + +# Issue #36 compliant. +if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || \ + (! [ "$TREAT_UNKNOWN_AS_UP" = "1" ] && + ! [ "`cat /sys/class/net/${INTERFACE}/operstate`" = "up" ]) +then + echo "$INTERFACE down" + echo "$INTERFACE down" + echo "#FF0000" + exit 0 +fi + +# path to store the old results in +path="/dev/shm/$(basename $0)-${INTERFACE}" + +# grabbing data for each adapter. +read rx < "/sys/class/net/${INTERFACE}/statistics/rx_bytes" +read tx < "/sys/class/net/${INTERFACE}/statistics/tx_bytes" + +# get time +time=$(date +%s) + +# write current data if file does not exist. Do not exit, this will cause +# problems if this file is sourced instead of executed as another process. +if ! [[ -f "${path}" ]]; then + echo "${time} ${rx} ${tx}" > "${path}" + chmod 0666 "${path}" +fi + + +# read previous state and update data storage +read old < "${path}" +echo "${time} ${rx} ${tx}" > "${path}" + +# parse old data and calc time passed +old=(${old//;/ }) +time_diff=$(( $time - ${old[0]} )) + +# sanity check: has a positive amount of time passed +[[ "${time_diff}" -gt 0 ]] || exit + +# calc bytes transferred, and their rate in byte/s +rx_diff=$(( $rx - ${old[1]} )) +tx_diff=$(( $tx - ${old[2]} )) +rx_rate=$(( $rx_diff / $time_diff )) +tx_rate=$(( $tx_diff / $time_diff )) + +# shift by 10 bytes to get KiB/s. If the value is larger than +# 1024^2 = 1048576, then display MiB/s instead + +# incoming +echo -n "$INLABEL" +rx_kib=$(( $rx_rate >> 10 )) +if hash bc 2>/dev/null && [[ "$rx_rate" -gt 1048576 ]]; then + printf '%sM' "`echo "scale=1; $rx_kib / 1024" | bc`" +else + echo -n "${rx_kib}K" +fi + +echo -n " " + +# outgoing +echo -n "$OUTLABEL" +tx_kib=$(( $tx_rate >> 10 )) +if hash bc 2>/dev/null && [[ "$tx_rate" -gt 1048576 ]]; then + printf '%sM\n' "`echo "scale=1; $tx_kib / 1024" | bc`" +else + echo "${tx_kib}K" +fi diff --git a/.config/i3blocks/bandwidth/bandwidth.png b/.config/i3blocks/bandwidth/bandwidth.png new file mode 100644 index 0000000..2552abd Binary files /dev/null and b/.config/i3blocks/bandwidth/bandwidth.png differ diff --git a/.config/i3blocks/bandwidth/i3blocks.conf b/.config/i3blocks/bandwidth/i3blocks.conf new file mode 100644 index 0000000..ab5e608 --- /dev/null +++ b/.config/i3blocks/bandwidth/i3blocks.conf @@ -0,0 +1,4 @@ +[bandwidth] +command=$SCRIPT_DIR/bandwidth +interval=5 +INTERFACE=eth0 diff --git a/.config/i3blocks/bandwidth2/.gitignore b/.config/i3blocks/bandwidth2/.gitignore new file mode 100644 index 0000000..0c1a301 --- /dev/null +++ b/.config/i3blocks/bandwidth2/.gitignore @@ -0,0 +1 @@ +bandwidth2 diff --git a/.config/i3blocks/bandwidth2/Makefile b/.config/i3blocks/bandwidth2/Makefile new file mode 100644 index 0000000..ef5c58c --- /dev/null +++ b/.config/i3blocks/bandwidth2/Makefile @@ -0,0 +1,6 @@ +P=bandwidth2 +OBJECTS= +CFLAGS=-g -Wall -Werror -O2 -std=c11 +LDLIBS= + +$(P): $(OBJECTS) diff --git a/.config/i3blocks/bandwidth2/README.md b/.config/i3blocks/bandwidth2/README.md new file mode 100644 index 0000000..0a5ecef --- /dev/null +++ b/.config/i3blocks/bandwidth2/README.md @@ -0,0 +1,49 @@ +# bandwidth2 + +Monitor bandwidth usage. +This is a C version of the bandwidth blocklet. + +![](bandwidth2.png) + +It comes with some other features though: +* Automatically estimate what unit (K,M,G,T) to use depending on the value. You can still choose between bits and bytes. +* By default sum all the network interfaces (except lo) instead of only default route interface. +* Warning and critical colors as an option. +* Choice for SI units or binary units. + +## Build + +``` +make +``` + +### Config +```ini +[bandwidth] +command=$SCRIPT_DIR/bandwidth2 +interval=persist +markup=pango +LABEL= +#INTERFACE=(checks all interfaces) +#USE_BITS=0 +#USE_BYTES=1 +#WARN_RX=0 +#WARN_TX=0 +#CRIT_RX=0 +#CRIT_TX=0 +#USE_SI=0 +``` + +E.g. + +```ini +[bandwidth] +command=$SCRIPT_DIR/bandwidth2 +interval=persist +markup=pango +LABEL= +WARN_RX=307200 +WARN_TX=30720 +CRIT_RX=512000 +CRIT_TX=51200 +``` diff --git a/.config/i3blocks/bandwidth2/bandwidth2.c b/.config/i3blocks/bandwidth2/bandwidth2.c new file mode 100644 index 0000000..2ce75b6 --- /dev/null +++ b/.config/i3blocks/bandwidth2/bandwidth2.c @@ -0,0 +1,227 @@ +#define _DEFAULT_SOURCE +#include +#include +#include +#include +#include +#include + +#define RED "#FF7373" +#define ORANGE "#FFA500" + +typedef unsigned long long int ulli; + +enum { + STATE_OK, + STATE_WARNING, + STATE_CRITICAL, + STATE_UNKNOWN, +}; + +void usage(char *argv[]) +{ + printf("Usage: %s [-b|B] [-t seconds] [-i interface] [-w Bytes:Bytes] [-c Bytes:Bytes] [-s] [-h]\n", argv[0]); + printf("\n"); + printf("-b \t\tuse bits/s\n"); + printf("-B \t\tuse Bytes/s (default)\n"); + printf("-t seconds\trefresh time (default is 1)\n"); + printf("-i interfaces\tnetwork interfaces to monitor (comma separated).\n"); + printf(" \tIf not specified, check all interfaces.\n"); + printf("-w Bytes:Bytes\tSet warning (color orange) for Rx:Tx bandwidth. (default: none)\n"); + printf("-c Bytes:Bytes\tSet critical (color red) for Rx:Tx bandwidth. (default: none)\n"); + printf("-s \t\tuse SI units\n"); + printf("-h \t\tthis help\n"); + printf("\n"); +} + +void get_values(char **const ifaces, int num_ifaces, time_t * const s, ulli * const received, ulli * const sent) +{ + FILE *f; + + f = fopen("/proc/net/dev", "r"); + if (!f) { + fprintf(stderr, "Can't open /proc/net/dev\n"); + exit(STATE_UNKNOWN); + } + + ulli temp_r, temp_s; + char line[BUFSIZ] = {0}; + char ifname[BUFSIZ]; + + *received = 0; + *sent = 0; + while (fgets(line, BUFSIZ - 1, f) != NULL) { + if (sscanf(line, "%[^:]: %llu %*u %*u %*u %*u %*u %*u %*u %llu", ifname, &temp_r, &temp_s) == 3) { + int i; + int iface_found = num_ifaces == 0; + for (i = 0; i < num_ifaces; i++) { + if (strcmp(ifaces[i], ifname) != 0) { + iface_found = 1; + break; + } + } + + if (!iface_found || strcmp(ifname, "lo") == 0) + continue; + + *received = *received + temp_r; + *sent = *sent + temp_s; + } + } + + fclose(f); + + *s = time(NULL); + if (!s) { + fprintf(stderr, "Can't get Epoch time\n"); + exit(STATE_UNKNOWN); + } +} + +void display(int const unit, int const divisor, + double b, int const warning, int const critical) +{ + char fmtstr[7]; + + if (critical != 0 && b > critical) { + printf("", RED); + } else if (warning != 0 && b > warning) { + printf("", ORANGE); + } else { + printf(""); + } + + if (unit == 'b') + b = b * 8; + + snprintf(fmtstr, sizeof (fmtstr), "%%%d.1lf ", divisor > 1000 ? 6 : 5); + + if (b < divisor) { + printf(fmtstr, b); + printf(" %c/s", unit); + } else if (b < divisor * divisor) { + printf(fmtstr, b / divisor); + printf("K%c/s", unit); + } else if (b < divisor * divisor * divisor) { + printf(fmtstr, b / (divisor * divisor)); + printf("M%c/s", unit); + } else { + printf(fmtstr, b / (divisor * divisor * divisor)); + printf("G%c/s", unit); + } + printf(""); +} + +void parse_ifaces(char *str, char ***ifaces, int *num_ifaces) +{ + int max_ifaces = strlen(str) / 2 + 1; + + *ifaces = calloc(max_ifaces, sizeof (char *)); + *num_ifaces = 0; + while (((*ifaces)[*num_ifaces] = strsep(&str, ","))) { + if ((*ifaces)[*num_ifaces] != NULL && (*ifaces)[*num_ifaces][0] != '\0') { + (*num_ifaces)++; + } + } +} + +int main(int argc, char *argv[]) +{ + int c, unit = 'B', t = 1; + char str_ifaces[BUFSIZ] = {0}; + char **ifaces; + int num_ifaces; + int warningrx = 0, warningtx = 0, criticalrx = 0, criticaltx = 0; + int divisor = 1024; + char *envvar = NULL; + char *label = ""; + + envvar = getenv("USE_BITS"); + if (envvar && *envvar == '1') + unit = 'b'; + envvar = getenv("USE_BYTES"); + if (envvar && *envvar == '1') + unit = 'B'; + envvar = getenv("REFRESH_TIME"); + if (envvar) + t = atoi(envvar); + envvar = getenv("INTERFACE"); + if (envvar) + snprintf(str_ifaces, BUFSIZ, "%s", envvar); + envvar = getenv("INTERFACES"); + if (envvar) + snprintf(str_ifaces, BUFSIZ, "%s", envvar); + envvar = getenv("WARN_RX"); + if (envvar) + warningrx = atoi(envvar); + envvar = getenv("WARN_TX"); + if (envvar) + warningtx = atoi(envvar); + envvar = getenv("CRIT_RX"); + if (envvar) + criticalrx = atoi(envvar); + envvar = getenv("CRIT_TX"); + if (envvar) + criticaltx = atoi(envvar); + envvar = getenv("USE_SI"); + if (envvar && *envvar == '1') + divisor = 1000; + envvar = getenv("LABEL"); + if (envvar) + label = envvar; + + while (c = getopt(argc, argv, "bBsht:i:w:c:"), c != -1) { + switch (c) { + case 'b': + case 'B': + unit = c; + break; + case 't': + t = atoi(optarg); + break; + case 'i': + snprintf(str_ifaces, BUFSIZ, "%s", optarg); + break; + case 'w': + sscanf(optarg, "%d:%d", &warningrx, &warningtx); + break; + case 'c': + sscanf(optarg, "%d:%d", &criticalrx, &criticaltx); + break; + case 's': + divisor = 1000; + break; + case 'h': + usage(argv); + return STATE_UNKNOWN; + } + } + + parse_ifaces(str_ifaces, &ifaces, &num_ifaces); + + time_t s, s_old; + ulli received, sent, received_old, sent_old; + double rx, tx; + + get_values(ifaces, num_ifaces, &s_old, &received_old, &sent_old); + + while (1) { + sleep(t); + get_values(ifaces, num_ifaces, &s, &received, &sent); + + rx = (received - received_old) / (float)(s - s_old); + tx = (sent - sent_old) / (float)(s - s_old); + printf("%s", label); + display(unit, divisor, rx, warningrx, criticalrx); + printf(" "); + display(unit, divisor, tx, warningtx, criticaltx); + printf("\n"); + fflush(stdout); + s_old = s; + received_old = received; + sent_old = sent; + } + + free(ifaces); + return STATE_OK; +} diff --git a/.config/i3blocks/bandwidth2/bandwidth2.png b/.config/i3blocks/bandwidth2/bandwidth2.png new file mode 100644 index 0000000..76bdd14 Binary files /dev/null and b/.config/i3blocks/bandwidth2/bandwidth2.png differ diff --git a/.config/i3blocks/bandwidth3/LICENSE b/.config/i3blocks/bandwidth3/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/bandwidth3/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/bandwidth3/README.md b/.config/i3blocks/bandwidth3/README.md new file mode 100644 index 0000000..32d600b --- /dev/null +++ b/.config/i3blocks/bandwidth3/README.md @@ -0,0 +1,28 @@ +# bandwidth3 + +Monitor bandwidth usage. + +![](bandwidth3.png) + +# Usage + +``` +[bandwidth3] +command=$SCRIPT_DIR/bandwidth3 +interval=persist +markup=pango +#LABEL= +#IFACE=[automatically determined] +#DT=3 +#UNIT=Mb +# Exposed variables: rx, wx, tx, unit, iface +#PRINTF_COMMAND=printf "${LABEL}%-5.1f/%5.1f %s/s\n", rx, wx, unit; +``` + +Note that the interface will be guessed using `ip route` but it can also be specified +using the `$IFACE` property. +On the fly interface switching is not supported, if you change +your default interface, simply issue `i3-msg restart` and the script will pick +up on the new default. However, the block will wait until a default interface +is found upon starting, so no restart is needed if you start i3 and then connect +to wifi later. diff --git a/.config/i3blocks/bandwidth3/bandwidth3 b/.config/i3blocks/bandwidth3/bandwidth3 new file mode 100755 index 0000000..53868a5 --- /dev/null +++ b/.config/i3blocks/bandwidth3/bandwidth3 @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2015 James Murphy +# Licensed under the terms of the GNU GPL v2 only. +# +# i3blocks blocklet script to monitor bandwidth usage + +iface="${BLOCK_INSTANCE}" +iface="${IFACE:-$iface}" +dt="${DT:-3}" +unit="${UNIT:-Mb}" +LABEL="${LABEL:- }" # down arrow up arrow +printf_command="${PRINTF_COMMAND:-"printf \"${LABEL}%-5.1f/%5.1f %s/s\\n\", rx, wx, unit;"}" + +function default_interface { + ip route | awk '/^default via/ {print $5; exit}' +} + +function check_proc_net_dev { + if [ ! -f "/proc/net/dev" ]; then + echo "/proc/net/dev not found" + exit 1 + fi +} + +function list_interfaces { + check_proc_net_dev + echo "Interfaces in /proc/net/dev:" + grep -o "^[^:]\\+:" /proc/net/dev | tr -d " :" +} + +while getopts i:t:u:p:lh opt; do + case "$opt" in + i) iface="$OPTARG" ;; + t) dt="$OPTARG" ;; + u) unit="$OPTARG" ;; + p) printf_command="$OPTARG" ;; + l) list_interfaces && exit 0 ;; + h) printf \ +"Usage: bandwidth3 [-i interface] [-t time] [-u unit] [-p printf_command] [-l] [-h] +Options: +-i\tNetwork interface to measure. Default determined using \`ip route\`. +-t\tTime interval in seconds between measurements. Default: 3 +-u\tUnits to measure bytes in. Default: Mb +\tAllowed units: Kb, KB, Mb, MB, Gb, GB, Tb, TB +\tUnits may have optional it/its/yte/ytes on the end, e.g. Mbits, KByte +-p\tAwk command to be called after a measurement is made. +\tDefault: printf \" %%-5.1f/%%5.1f %%s/s\\\\n\", rx, wx, unit; +\tExposed variables: rx, wx, tx, unit, iface +-l\tList available interfaces in /proc/net/dev +-h\tShow this help text +" && exit 0;; + esac +done + +check_proc_net_dev + +iface="${iface:-$(default_interface)}" +while [ -z "$iface" ]; do + echo No default interface + sleep "$dt" + iface=$(default_interface) +done + +case "$unit" in + Kb|Kbit|Kbits) bytes_per_unit=$((1024 / 8));; + KB|KByte|KBytes) bytes_per_unit=$((1024));; + Mb|Mbit|Mbits) bytes_per_unit=$((1024 * 1024 / 8));; + MB|MByte|MBytes) bytes_per_unit=$((1024 * 1024));; + Gb|Gbit|Gbits) bytes_per_unit=$((1024 * 1024 * 1024 / 8));; + GB|GByte|GBytes) bytes_per_unit=$((1024 * 1024 * 1024));; + Tb|Tbit|Tbits) bytes_per_unit=$((1024 * 1024 * 1024 * 1024 / 8));; + TB|TByte|TBytes) bytes_per_unit=$((1024 * 1024 * 1024 * 1024));; + *) echo Bad unit "$unit" && exit 1;; +esac + +scalar=$((bytes_per_unit * dt)) +init_line=$(cat /proc/net/dev | grep "^[ ]*$iface:") +if [ -z "$init_line" ]; then + echo Interface not found in /proc/net/dev: "$iface" + exit 1 +fi + +init_received=$(awk '{print $2}' <<< $init_line) +init_sent=$(awk '{print $10}' <<< $init_line) + +(while true; do cat /proc/net/dev; sleep "$dt"; done) |\ + stdbuf -oL grep "^[ ]*$iface:" |\ + awk -v scalar="$scalar" -v unit="$unit" -v iface="$iface" ' +BEGIN{old_received='"$init_received"';old_sent='"$init_sent"'} +{ + received=$2 + sent=$10 + rx=(received-old_received)/scalar; + wx=(sent-old_sent)/scalar; + tx=rx+wr; + old_received=received; + old_sent=sent; + if(rx >= 0 && wx >= 0){ + '"$printf_command"'; + fflush(stdout); + } +} +' diff --git a/.config/i3blocks/bandwidth3/bandwidth3.png b/.config/i3blocks/bandwidth3/bandwidth3.png new file mode 100644 index 0000000..fc4b009 Binary files /dev/null and b/.config/i3blocks/bandwidth3/bandwidth3.png differ diff --git a/.config/i3blocks/bandwidth3/i3blocks.conf b/.config/i3blocks/bandwidth3/i3blocks.conf new file mode 100644 index 0000000..b2930c3 --- /dev/null +++ b/.config/i3blocks/bandwidth3/i3blocks.conf @@ -0,0 +1,10 @@ +[bandwidth3] +command=$SCRIPT_DIR/bandwidth3 +interval=persist +markup=pango +#LABEL= +#IFACE=[automatically determined] +#DT=3 +#UNIT=Mb +# Exposed variables: rx, wx, tx, unit, iface +#PRINTF_COMMAND=printf "${LABEL}%-5.1f/%5.1f %s/s\n", rx, wx, unit; diff --git a/.config/i3blocks/battery/README.md b/.config/i3blocks/battery/README.md new file mode 100644 index 0000000..5f14bdb --- /dev/null +++ b/.config/i3blocks/battery/README.md @@ -0,0 +1,20 @@ +# battery + +Show battery info. + +![](battery.png) + +# Dependencies + +* `acpi` + +# Config + +``` +[battery] +command=$SCRIPT_DIR/battery +interval=30 +LABEL=BAT +#LABEL=⚡ +#BAT_NUMBER=0 +``` diff --git a/.config/i3blocks/battery/battery b/.config/i3blocks/battery/battery new file mode 100755 index 0000000..b5f0a57 --- /dev/null +++ b/.config/i3blocks/battery/battery @@ -0,0 +1,94 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# +# Licensed under the terms of the GNU GPL v3, or any later version. +# +# This script is meant to use with i3blocks. It parses the output of the "acpi" +# command (often provided by a package of the same name) to read the status of +# the battery, and eventually its remaining time (to full charge or discharge). +# +# The color will gradually change for a percentage below 85%, and the urgency +# (exit code 33) is set if there is less that 5% remaining. + +use strict; +use warnings; +use utf8; + +my $acpi; +my $status; +my $percent; +my $ac_adapt; +my $full_text; +my $short_text; +my $bat_number = $ENV{BAT_NUMBER} || 0; +my $label = $ENV{LABEL} || ""; + +# read the first line of the "acpi" command output +open (ACPI, "acpi -b 2>/dev/null| grep 'Battery $bat_number' |") or die; +$acpi = ; +close(ACPI); + +# fail on unexpected output +if (not defined($acpi)) { + # don't print anything to stderr if there is no battery + exit(0); +} +elsif ($acpi !~ /: ([\w\s]+), (\d+)%/) { + die "$acpi\n"; +} + +$status = $1; +$percent = $2; +$full_text = "$label$percent%"; + +if ($status eq 'Discharging') { + $full_text .= ' DIS'; +} elsif ($status eq 'Charging') { + $full_text .= ' CHR'; +} elsif ($status eq 'Unknown') { + open (AC_ADAPTER, "acpi -a |") or die; + $ac_adapt = ; + close(AC_ADAPTER); + + if ($ac_adapt =~ /: ([\w-]+)/) { + $ac_adapt = $1; + + if ($ac_adapt eq 'on-line') { + $full_text .= ' CHR'; + } elsif ($ac_adapt eq 'off-line') { + $full_text .= ' DIS'; + } + } +} + +$short_text = $full_text; + +if ($acpi =~ /(\d\d:\d\d):/) { + $full_text .= " ($1)"; +} + +# print text +print "$full_text\n"; +print "$short_text\n"; + +# consider color and urgent flag only on discharge +if ($status eq 'Discharging') { + + if ($percent < 20) { + print "#FF0000\n"; + } elsif ($percent < 40) { + print "#FFAE00\n"; + } elsif ($percent < 60) { + print "#FFF600\n"; + } elsif ($percent < 85) { + print "#A8FF00\n"; + } + + if ($percent < 5) { + exit(33); + } +} + +exit(0); diff --git a/.config/i3blocks/battery/battery.png b/.config/i3blocks/battery/battery.png new file mode 100644 index 0000000..3bf89ba Binary files /dev/null and b/.config/i3blocks/battery/battery.png differ diff --git a/.config/i3blocks/battery/i3blocks.conf b/.config/i3blocks/battery/i3blocks.conf new file mode 100644 index 0000000..18b3968 --- /dev/null +++ b/.config/i3blocks/battery/i3blocks.conf @@ -0,0 +1,6 @@ +[battery] +command=$SCRIPT_DIR/battery +interval=30 +LABEL=BAT +#LABEL=⚡ +#BAT_NUMBER=0 diff --git a/.config/i3blocks/battery2/LICENSE b/.config/i3blocks/battery2/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/battery2/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/battery2/README.md b/.config/i3blocks/battery2/README.md new file mode 100644 index 0000000..6a286b7 --- /dev/null +++ b/.config/i3blocks/battery2/README.md @@ -0,0 +1,28 @@ +# battery2 + +Show the current status of your battery. + +![](images/full.png) + +![](images/charging.png) + +![](images/unplugged.png) + +![](images/unknown.png) + +![](images/nobattery.png) + +# Dependencies + +fonts-font-awesome, acpi, python3 + +# Installation + +To use with i3blocks, copy the blocklet configuration in the given `i3blocks.conf` into your i3blocks configuration file, the recommended config is + +```INI +[battery2] +command=$SCRIPT_DIR/battery2 +markup=pango +interval=30 +``` diff --git a/.config/i3blocks/battery2/battery2 b/.config/i3blocks/battery2/battery2 new file mode 100755 index 0000000..b23dfdd --- /dev/null +++ b/.config/i3blocks/battery2/battery2 @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 James Murphy +# Licensed under the GPL version 2 only +# +# A battery indicator blocklet script for i3blocks + +import re +from subprocess import check_output + +status = check_output(['acpi'], universal_newlines=True) + +if not status: + # stands for no battery found + fulltext = "\uf00d \uf240" + percentleft = 100 +else: + # if there is more than one battery in one laptop, the percentage left is + # available for each battery separately, although state and remaining + # time for overall block is shown in the status of the first battery + batteries = status.split("\n") + state_batteries=[] + commasplitstatus_batteries=[] + percentleft_batteries=[] + time = "" + for battery in batteries: + if battery!='': + state_batteries.append(battery.split(": ")[1].split(", ")[0]) + commasplitstatus = battery.split(", ") + if not time: + time = commasplitstatus[-1].strip() + # check if it matches a time + time = re.match(r"(\d+):(\d+)", time) + if time: + time = ":".join(time.groups()) + timeleft = " ({})".format(time) + else: + timeleft = "" + + p = int(commasplitstatus[1].rstrip("%\n")) + if p>0: + percentleft_batteries.append(p) + commasplitstatus_batteries.append(commasplitstatus) + state = state_batteries[0] + commasplitstatus = commasplitstatus_batteries[0] + if percentleft_batteries: + percentleft = int(sum(percentleft_batteries)/len(percentleft_batteries)) + else: + percentleft = 0 + + # stands for charging + FA_LIGHTNING = "\uf0e7" + + # stands for plugged in + FA_PLUG = "\uf1e6" + + # stands for using battery + FA_BATTERY = "\uf240" + + # stands for unknown status of battery + FA_QUESTION = "\uf128" + + + if state == "Discharging": + fulltext = FA_BATTERY + " " + elif state == "Full": + fulltext = FA_PLUG + " " + timeleft = "" + elif state == "Unknown": + fulltext = FA_QUESTION + " " + FA_BATTERY + " " + timeleft = "" + else: + fulltext = FA_LIGHTNING + " " + FA_PLUG + " " + + def color(percent): + if percent < 10: + # exit code 33 will turn background red + return "#FFFFFF" + if percent < 20: + return "#FF3300" + if percent < 30: + return "#FF6600" + if percent < 40: + return "#FF9900" + if percent < 50: + return "#FFCC00" + if percent < 60: + return "#FFFF00" + if percent < 70: + return "#FFFF33" + if percent < 80: + return "#FFFF66" + return "#FFFFFF" + + form = '{}%' + fulltext += form.format(color(percentleft), percentleft) + fulltext += timeleft + +print(fulltext) +print(fulltext) +if percentleft < 10: + exit(33) diff --git a/.config/i3blocks/battery2/i3blocks.conf b/.config/i3blocks/battery2/i3blocks.conf new file mode 100644 index 0000000..74aacd4 --- /dev/null +++ b/.config/i3blocks/battery2/i3blocks.conf @@ -0,0 +1,4 @@ +[battery2] +command=$SCRIPT_DIR/battery2 +markup=pango +interval=30 diff --git a/.config/i3blocks/battery2/images/charging.png b/.config/i3blocks/battery2/images/charging.png new file mode 100644 index 0000000..bf616f1 Binary files /dev/null and b/.config/i3blocks/battery2/images/charging.png differ diff --git a/.config/i3blocks/battery2/images/full.png b/.config/i3blocks/battery2/images/full.png new file mode 100644 index 0000000..f585743 Binary files /dev/null and b/.config/i3blocks/battery2/images/full.png differ diff --git a/.config/i3blocks/battery2/images/nobattery.png b/.config/i3blocks/battery2/images/nobattery.png new file mode 100644 index 0000000..be7ad1b Binary files /dev/null and b/.config/i3blocks/battery2/images/nobattery.png differ diff --git a/.config/i3blocks/battery2/images/unknown.png b/.config/i3blocks/battery2/images/unknown.png new file mode 100644 index 0000000..fa03c69 Binary files /dev/null and b/.config/i3blocks/battery2/images/unknown.png differ diff --git a/.config/i3blocks/battery2/images/unplugged.png b/.config/i3blocks/battery2/images/unplugged.png new file mode 100644 index 0000000..3b8e02e Binary files /dev/null and b/.config/i3blocks/battery2/images/unplugged.png differ diff --git a/.config/i3blocks/batterybar/LICENSE b/.config/i3blocks/batterybar/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/.config/i3blocks/batterybar/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/.config/i3blocks/batterybar/README.md b/.config/i3blocks/batterybar/README.md new file mode 100644 index 0000000..d22b918 --- /dev/null +++ b/.config/i3blocks/batterybar/README.md @@ -0,0 +1,43 @@ +# batterybar + +Display the battery level in a set of five unicode squares (U+25A0). + +![](screenshot.png) + +It also changes color for more accuracy and to distinguish between charging, +discharging, charged, and AC statuses. + +You can also specify your own set of colors. + +Left-clicking briefly shows the battery level in percent. + +# Dependencies + +* acpi + +# Installation + +* Copy the batterybar script into your directory of choice, e.g. ~/.i3blocks/ +* Give it execution permission (`chmod +x batterybar`) +* Add the following blocket to your i3blocks.conf: + +```ini +[batterybar] +command=$SCRIPT_DIR/batterybar +label=bat: +interval=5 +markup=pango +min_width=bat: ■■■■■ +# Discharging colors low to high +#C1=#FF0027 +#C2=#FF3B05 +#C3=#FFB923 +#C4=#FFD000 +#C5=#E4FF00 +#C6=#ADFF00 +#C7=#6DFF00 +#C8=#10BA00 +#CHARGING_COLOR=#00AFE3 +#FULL_COLOR=#FFFFFF +#AC_COLOR=#535353 +``` diff --git a/.config/i3blocks/batterybar/batterybar b/.config/i3blocks/batterybar/batterybar new file mode 100755 index 0000000..0308aba --- /dev/null +++ b/.config/i3blocks/batterybar/batterybar @@ -0,0 +1,137 @@ +#!/usr/bin/env bash +# batterybar; displays battery percentage as a bar on i3blocks +# +# Copyright 2015 Keftaa +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# +readarray -t output <<< $(acpi battery) +battery_count=${#output[@]} + +for line in "${output[@]}"; +do + percentages+=($(echo "$line" | grep -o -m1 '[0-9]\{1,3\}%' | tr -d '%')) + statuses+=($(echo "$line" | egrep -o -m1 'Discharging|Charging|AC|Full|Unknown')) + remaining=$(echo "$line" | egrep -o -m1 '[0-9][0-9]:[0-9][0-9]') + if [[ -n $remaining ]]; then + remainings+=(" ($remaining)") + else + remainings+=("") + fi +done + +squares="■" + +#There are 8 colors that reflect the current battery percentage when +#discharging +dis_colors=("${C1:-#FF0027}" "${C2:-#FF3B05}" "${C3:-#FFB923}" + "${C4:-#FFD000}" "${C5:-#E4FF00}" "${C6:-#ADFF00}" + "${C7:-#6DFF00}" "${C8:-#10BA00}") +charging_color="${CHARGING_COLOR:-#00AFE3}" +full_color="${FULL_COLOR:-#FFFFFF}" +ac_color="${AC_COLOR:-#535353}" + + +while getopts 1:2:3:4:5:6:7:8:c:f:a:h opt; do + case "$opt" in + 1) dis_colors[0]="$OPTARG";; + 2) dis_colors[1]="$OPTARG";; + 3) dis_colors[2]="$OPTARG";; + 4) dis_colors[3]="$OPTARG";; + 5) dis_colors[4]="$OPTARG";; + 6) dis_colors[5]="$OPTARG";; + 7) dis_colors[6]="$OPTARG";; + 8) dis_colors[7]="$OPTARG";; + c) charging_color="$OPTARG";; + f) full_color="$OPTARG";; + a) ac_color="$OPTARG";; + h) printf "Usage: batterybar [OPTION] color + When discharging, there are 8 [1-8] levels colors. + You can specify custom colors, for example: + + batterybar -1 red -2 \"#F6F6F6\" -8 green + + You can also specify the colors for the charging, AC and + charged states: + + batterybar -c green -f white -a \"#EEEEEE\"\n"; + exit 0; + esac +done + +end=$(($battery_count - 1)) +for i in $(seq 0 $end); +do + if (( percentages[$i] > 0 && percentages[$i] < 20 )); then + squares="■" + elif (( percentages[$i] >= 20 && percentages[$i] < 40 )); then + squares="■■" + elif (( percentages[$i] >= 40 && percentages[$i] < 60 )); then + squares="■■■" + elif (( percentages[$i] >= 60 && percentages[$i] < 80 )); then + squares="■■■■" + elif (( percentages[$i] >=80 )); then + squares="■■■■■" + fi + + if [[ "${statuses[$i]}" = "Unknown" ]]; then + squares="?$squares" + fi + + case "${statuses[$i]}" in + "Charging") + color="$charging_color" + ;; + "Full") + color="$full_color" + ;; + "AC") + color="$ac_color" + ;; + "Discharging"|"Unknown") + if (( percentages[$i] >= 0 && percentages[$i] < 10 )); then + color="${dis_colors[0]}" + elif (( percentages[$i] >= 10 && percentages[$i] < 20 )); then + color="${dis_colors[1]}" + elif (( percentages[$i] >= 20 && percentages[$i] < 30 )); then + color="${dis_colors[2]}" + elif (( percentages[$i] >= 30 && percentages[$i] < 40 )); then + color="${dis_colors[3]}" + elif (( percentages[$i] >= 40 && percentages[$i] < 60 )); then + color="${dis_colors[4]}" + elif (( percentages[$i] >= 60 && percentages[$i] < 70 )); then + color="${dis_colors[5]}" + elif (( percentages[$i] >= 70 && percentages[$i] < 80 )); then + color="${dis_colors[6]}" + elif (( percentages[$i] >= 80 )); then + color="${dis_colors[7]}" + fi + ;; + esac + + # Print Battery number if there is more than one + if (( $end > 0 )) ; then + message="$message $(($i + 1)):" + fi + + if [[ "$BLOCK_BUTTON" -eq 1 ]]; then + message="$message ${statuses[$i]} ${percentages[$i]}%${remainings[i]}" + fi + message="$message $squares" +done + +echo $message diff --git a/.config/i3blocks/batterybar/screenshot.png b/.config/i3blocks/batterybar/screenshot.png new file mode 100644 index 0000000..d55c221 Binary files /dev/null and b/.config/i3blocks/batterybar/screenshot.png differ diff --git a/.config/i3blocks/caffeine/caffeine b/.config/i3blocks/caffeine/caffeine new file mode 100755 index 0000000..1dd3fb0 --- /dev/null +++ b/.config/i3blocks/caffeine/caffeine @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ -f /tmp/caffeine.$USER ]; then + echo "on" +fi diff --git a/.config/i3blocks/calendar/README.md b/.config/i3blocks/calendar/README.md new file mode 100644 index 0000000..bf29b5b --- /dev/null +++ b/.config/i3blocks/calendar/README.md @@ -0,0 +1,48 @@ +# calendar + +Shows the current date and time. When clicked, a calendar popup is created. + +This is similar to the rofi-calendar blocklet, but without the rofi dependency and with a slightly more advanced popup (at least in my opinion). + +![](screenshot1.png) + +![](screenshot2.png) + +# Dependencies + +* yad +* xdotool (for positioning of the popup) + +# Installation + +* Copy the script into your directory of choice, e.g. ~/.i3blocks/blocklets +* Give it execution permission (`chmod +x calendar`) +* Add the script to your i3blocks.conf, for example like this: + +```ini +[calendar] +command=$SCRIPT_DIR/calendar +interval=1 +LABEL= +DATEFMT=+%H:%M:%S +# SHORTFMT=+%H:%M:%S +HEIGHT=180 +WIDTH=220 +``` + +* Add `for_window [class="Yad"] floating enable` to your i3 config file. +Unfortunately this is neccessary [because of a bug in `yad`](https://sourceforge.net/p/yad-dialog/tickets/301/). +You may skip this step if you want to open the calendar popup as a normal tile instead. + +# Configuration + +Parameters _[deprecated!]_: + +* `-f FMT`: date/time format (default _+%a %d.%m.%Y %H:%M:%S_) +* `-W WIDTH`: width of the window (default _200_) +* `-H HEIGHT`: height of the window (default _200_) + +Additionally you may want to + +* change the placement of the popup +* change the parameters for `yad` to change the appearance of the popup diff --git a/.config/i3blocks/calendar/calendar b/.config/i3blocks/calendar/calendar new file mode 100755 index 0000000..4ec7d81 --- /dev/null +++ b/.config/i3blocks/calendar/calendar @@ -0,0 +1,40 @@ +#! /bin/sh + +WIDTH=${WIDTH:-200} +HEIGHT=${HEIGHT:-200} +DATEFMT=${DATEFMT:-"+%a %d.%m.%Y %H:%M:%S"} +SHORTFMT=${SHORTFMT:-"+%H:%M:%S"} + +OPTIND=1 +while getopts ":f:W:H:" opt; do + case $opt in + f) DATEFMT="$OPTARG" ;; + W) WIDTH="$OPTARG" ;; + H) HEIGHT="$OPTARG" ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + +case "$BLOCK_BUTTON" in + 1|2|3) + + # the position of the upper left corner of the popup + posX=$(($BLOCK_X - $WIDTH / 2)) + posY=$(($BLOCK_Y - $HEIGHT)) + + i3-msg -q "exec yad --calendar \ + --width=$WIDTH --height=$HEIGHT \ + --undecorated --fixed \ + --close-on-unfocus --no-buttons \ + --posx=$posX --posy=$posY \ + > /dev/null" +esac +echo "$LABEL$(date "$DATEFMT")" +echo "$LABEL$(date "$SHORTFMT")" diff --git a/.config/i3blocks/calendar/screenshot1.png b/.config/i3blocks/calendar/screenshot1.png new file mode 100644 index 0000000..855afea Binary files /dev/null and b/.config/i3blocks/calendar/screenshot1.png differ diff --git a/.config/i3blocks/calendar/screenshot2.png b/.config/i3blocks/calendar/screenshot2.png new file mode 100644 index 0000000..7bcbb14 Binary files /dev/null and b/.config/i3blocks/calendar/screenshot2.png differ diff --git a/.config/i3blocks/config b/.config/i3blocks/config new file mode 100644 index 0000000..6fed5fd --- /dev/null +++ b/.config/i3blocks/config @@ -0,0 +1,165 @@ +# i3blocks config file +# +# Please see man i3blocks for a complete reference! +# The man page is also hosted at http://vivien.github.io/i3blocks +# +# List of valid properties: +# +# align +# color +# command +# full_text +# instance +# interval +# label +# min_width +# name +# separator +# separator_block_width +# short_text +# signal +# urgent + +# Global properties +# +# The top properties below are applied to every block, but can be overridden. +# Each block command defaults to the script name to avoid boilerplate. +# Change $SCRIPT_DIR to the location of your scripts! +command=$HOME/.config/i3blocks/$BLOCK_NAME/$BLOCK_NAME +separator_block_width=15 +markup=none + +# Volume indicator +# +# The first parameter sets the step (and units to display) +# The second parameter overrides the mixer selection +# See the script for details. + +[volume] +#label=♪ +label=vol +interval=once +signal=10 +#STEP=5% + +# Memory usage +# +# The type defaults to "mem" if the instance is not specified. +#[memory] +#label=mem +#separator=false +#interval=30 + +#[memory] +#label=SWAP +#instance=swap +#separator=false +#interval=30 + +# Disk usage +# +# The directory defaults to $HOME if the instance is not specified. +# The script may be called with a optional argument to set the alert +# (defaults to 10 for 10%). +[disk] +label=home +#DIR=/mnt/data +interval=30 + +# Network interface monitoring +# +# If the instance is not specified, use the interface used for default route. +# The address can be forced to IPv4 or IPv6 with -4 or -6 switches. +[iface] +#IFACE=wlan0 +color=#00FF00 +interval=10 + +[wifi] +#INTERFACE=wlp3s0 +label=wifi: +interval=10 +#separator=true + +#[bandwidth] +#INTERFACE=eth0 +#interval=5 + +# CPU usage +# +# The script may be called with -w and -c switches to specify thresholds, +# see the script for details. +#[cpu_usage] +#label=CPU +#interval=10 +#min_width=CPU 100.00% +#separator=false + +[load_average] +label=load +interval=10 + +[kernel] +label=kernel +interval=3600 + +[caffeine] +label=caffeine +interval=once +signal=13 +# +# Battery indicator +# +# The battery instance defaults to 0. +[battery] +label=BAT +#label=⚡ +interval=30 + +# Date Time +# +[time] +command=date '+%Y-%m-%d %H:%M:%S' +interval=1 + +# Generic media player support +# +# This displays "ARTIST - SONG" if a music is playing. +# Supported players are: spotify, vlc, audacious, xmms2, mplayer, and others. +#[mediaplayer] +#instance=spotify +#interval=5 +#signal=10 + +# OpenVPN support +# +# Support multiple VPN, with colors. +#[openvpn] +#interval=20 + +# Temperature +# +# Support multiple chips, though lm-sensors. +# The script may be called with -w and -c switches to specify thresholds, +# see the script for details. +#[temperature] +#label=TEMP +#interval=10 + +# Key indicators +# +# Add the following bindings to i3 config file: +# +# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks +# bindsym --release Num_Lock exec pkill -SIGRTMIN+11 i3blocks +#[keyindicator] +#KEY=CAPS +#markup=pango +#interval=once +#signal=11 + +#[keyindicator] +#KEY=NUM +#markup=pango +#interval=once +#signal=11 diff --git a/.config/i3blocks/cpu_usage/README.md b/.config/i3blocks/cpu_usage/README.md new file mode 100644 index 0000000..f6d8045 --- /dev/null +++ b/.config/i3blocks/cpu_usage/README.md @@ -0,0 +1,22 @@ +# cpu_usage + +Show CPU usage. + +![](cpu_usage.png) + +# Dependencies + +* `mpstat` + +# Config + +``` +[cpu_usage] +command=$SCRIPT_DIR/cpu_usage +interval=10 +LABEL=CPU +#min_width=CPU: 100.00% +#T_WARN=50 +#T_CRIT=80 +#DECIMALS=2 +``` diff --git a/.config/i3blocks/cpu_usage/cpu_usage b/.config/i3blocks/cpu_usage/cpu_usage new file mode 100755 index 0000000..44c1189 --- /dev/null +++ b/.config/i3blocks/cpu_usage/cpu_usage @@ -0,0 +1,62 @@ +#!/usr/bin/perl +# +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# Copyright 2014 Andreas Guldstrand +# +# Licensed under the terms of the GNU GPL v3, or any later version. + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +# default values +my $t_warn = $ENV{T_WARN} // 50; +my $t_crit = $ENV{T_CRIT} // 80; +my $cpu_usage = -1; +my $decimals = $ENV{DECIMALS} // 2; +my $label = $ENV{LABEL} // ""; + +sub help { + print "Usage: cpu_usage [-w ] [-c ] [-d ]\n"; + print "-w : warning threshold to become yellow\n"; + print "-c : critical threshold to become red\n"; + print "-d : Use decimals for percentage (default is $decimals) \n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit, + "d=i" => \$decimals, +); + +# Get CPU usage +$ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is +open (MPSTAT, 'mpstat 1 1 |') or die; +while () { + if (/^.*\s+(\d+\.\d+)[\s\x00]?$/) { + $cpu_usage = 100 - $1; # 100% - %idle + last; + } +} +close(MPSTAT); + +$cpu_usage eq -1 and die 'Can\'t find CPU information'; + +# Print short_text, full_text +print "${label}"; +printf "%.${decimals}f%%\n", $cpu_usage; +print "${label}"; +printf "%.${decimals}f%%\n", $cpu_usage; + +# Print color, if needed +if ($cpu_usage >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($cpu_usage >= $t_warn) { + print "#FFFC00\n"; +} + +exit 0; diff --git a/.config/i3blocks/cpu_usage/cpu_usage.png b/.config/i3blocks/cpu_usage/cpu_usage.png new file mode 100644 index 0000000..6b6f577 Binary files /dev/null and b/.config/i3blocks/cpu_usage/cpu_usage.png differ diff --git a/.config/i3blocks/cpu_usage/i3blocks.conf b/.config/i3blocks/cpu_usage/i3blocks.conf new file mode 100644 index 0000000..413c38d --- /dev/null +++ b/.config/i3blocks/cpu_usage/i3blocks.conf @@ -0,0 +1,8 @@ +[cpu_usage] +command=$SCRIPT_DIR/cpu_usage +interval=10 +LABEL=CPU +#min_width=CPU: 100.00% +#T_WARN=50 +#T_CRIT=80 +#DECIMALS=2 diff --git a/.config/i3blocks/cpu_usage2/.gitignore b/.config/i3blocks/cpu_usage2/.gitignore new file mode 100644 index 0000000..1cf1cd5 --- /dev/null +++ b/.config/i3blocks/cpu_usage2/.gitignore @@ -0,0 +1 @@ +cpu_usage2 diff --git a/.config/i3blocks/cpu_usage2/Makefile b/.config/i3blocks/cpu_usage2/Makefile new file mode 100644 index 0000000..02aeaaf --- /dev/null +++ b/.config/i3blocks/cpu_usage2/Makefile @@ -0,0 +1,6 @@ +P=cpu_usage2 +OBJECTS= +CFLAGS=-g -Wall -Werror -O2 -std=gnu11 +LDLIBS= + +$(P): $(OBJECTS) diff --git a/.config/i3blocks/cpu_usage2/README.md b/.config/i3blocks/cpu_usage2/README.md new file mode 100644 index 0000000..9be688f --- /dev/null +++ b/.config/i3blocks/cpu_usage2/README.md @@ -0,0 +1,21 @@ +# cpu_usage2 + +Show CPU usage. +This is a C version of the cpu_usage blocklet. + +![](cpu_usage2.png) + +# Config + +``` +[cpu_usage2] +command=$SCRIPT_DIR/cpu_usage2 +markup=pango +interval=persist +#min_width=CPU 100.00% +#REFRESH_TIME=1 +#LABEL=CPU +#WARN_PERCENT=50 +#CRIT_PERCENT=80 +#DECIMALS=2 +``` diff --git a/.config/i3blocks/cpu_usage2/cpu_usage2.c b/.config/i3blocks/cpu_usage2/cpu_usage2.c new file mode 100644 index 0000000..7270903 --- /dev/null +++ b/.config/i3blocks/cpu_usage2/cpu_usage2.c @@ -0,0 +1,135 @@ +// Licensed under the terms of the GNU GPL v3, or any later version. +// +// Copyright 2019 Nolan Leake +// +// Loosely based on bandwidth2 (originally by Guillaume Coré ) + +#include +#include +#include +#include +#include +#include + +#define RED "#FF7373" +#define ORANGE "#FFA500" + +typedef unsigned long long int ulli; + +void usage(char *argv[]) +{ + printf("Usage: %s " + "[-t seconds] [-w %%age] [-c %%age] [-d decimals] [-l label] [-h]\n", + argv[0]); + printf("\n"); + printf("-t seconds\trefresh time (default is 1)\n"); + printf("-w %%\tSet warning (color orange) for cpu usage. (default: none)\n"); + printf("-c %%\tSet critical (color red) for cpu usage. (default: none)\n"); + printf("-d number\tNumber of decimal places for percentage (default: 2)\n"); + printf("-l label\tLabel to print before the cpu usage (default: CPU)\n"); + printf("-h \t\tthis help\n"); + printf("\n"); +} + +void display(const char *label, double used, + int const warning, int const critical, int const decimals) +{ + if (critical != 0 && used > critical) { + printf("%s", label, RED); + } else if (warning != 0 && used > warning) { + printf("%s", label, ORANGE); + } else { + printf("%s", label); + } + + printf("%*.*lf%%\n", decimals + 3 + 1, decimals, used); +} + +ulli get_usage(ulli *used_jiffies) +{ + FILE *fd = fopen("/proc/stat", "r"); + ulli user, nice, sys, idle, iowait, irq, sirq, steal, guest, nguest; + + if (!fd) { + perror("Couldn't open /proc/stat\n"); + exit(EXIT_FAILURE); + } + if (fscanf(fd, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu", + &user, &nice, &sys, &idle, &iowait, &irq, &sirq, + &steal, &guest, &nguest) != 10) { + perror("Couldn't read jiffies from /proc/stat\n"); + exit(EXIT_FAILURE); + } + fclose(fd); + + *used_jiffies = user + nice + sys + irq + sirq + steal + guest + nguest; + return *used_jiffies + idle + iowait; +} + +int main(int argc, char *argv[]) +{ + int warning = 50, critical = 80, t = 1, decimals = 2; + char *label = "CPU "; + int c; + char *envvar = NULL; + + envvar = getenv("REFRESH_TIME"); + if (envvar) + t = atoi(envvar); + envvar = getenv("WARN_PERCENT"); + if (envvar) + warning = atoi(envvar); + envvar = getenv("CRIT_PERCENT"); + if (envvar) + critical = atoi(envvar); + envvar = getenv("DECIMALS"); + if (envvar) + decimals = atoi(envvar); + envvar = getenv("LABEL"); + if (envvar) + label = envvar; + + while (c = getopt(argc, argv, "ht:w:c:d:l:"), c != -1) { + switch (c) { + case 't': + t = atoi(optarg); + break; + case 'w': + warning = atoi(optarg); + break; + case 'c': + critical = atoi(optarg); + break; + case 'd': + decimals = atoi(optarg); + break; + case 'l': + label = optarg; + break; + case 'h': + usage(argv); + return EXIT_SUCCESS; + } + } + + ulli old_total; + ulli old_used; + + old_total = get_usage(&old_used); + + while (1) { + ulli used; + ulli total; + + sleep(t); + total = get_usage(&used); + + display(label, 100.0D * (used - old_used) / (total - old_total), + warning, critical, decimals); + fflush(stdout); + old_total = total; + old_used = used; + } + + return EXIT_SUCCESS; +} diff --git a/.config/i3blocks/cpu_usage2/cpu_usage2.png b/.config/i3blocks/cpu_usage2/cpu_usage2.png new file mode 100644 index 0000000..6b6f577 Binary files /dev/null and b/.config/i3blocks/cpu_usage2/cpu_usage2.png differ diff --git a/.config/i3blocks/cpu_usage2/i3blocks.conf b/.config/i3blocks/cpu_usage2/i3blocks.conf new file mode 100644 index 0000000..1f538ce --- /dev/null +++ b/.config/i3blocks/cpu_usage2/i3blocks.conf @@ -0,0 +1,10 @@ +[cpu_usage2] +command=$SCRIPT_DIR/cpu_usage2 +markup=pango +interval=persist +#min_width=CPU 100.00% +#REFRESH_TIME=1 +#LABEL=CPU +#WARN_PERCENT=50 +#CRIT_PERCENT=80 +#DECIMALS=2 diff --git a/.config/i3blocks/disk-io/LICENSE b/.config/i3blocks/disk-io/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/disk-io/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/disk-io/README.md b/.config/i3blocks/disk-io/README.md new file mode 100644 index 0000000..5f75301 --- /dev/null +++ b/.config/i3blocks/disk-io/README.md @@ -0,0 +1,62 @@ +# disk-io + +Monitor disk reads and writes. + +![](disk-io-1.png) + +![](disk-io-2.png) + +# Dependencies + +iostat (sysstat package), fontawesome for the  hard disk icon (fonts-font-awesome package) + +# Usage + +``` +[disk-io] +command=$SCRIPT_DIR/disk-io +#command=$SCRIPT_DIR/disk-io -w 3 -M -P 0 +interval=persist +markup=pango +LABEL= +#instance=/^sda/ +#DT=5 +#MB_ONLY=0 #0 or 1 +#KB_ONLY=0 #0 or 1 +#WIDTH=4 +#MB_PRECISION=1 +#KB_PRECISION=0 +#REGEX=/^(s|h)d[a-zA-Z]+/ +#THRESHOLD=0 +#WARN_COLOR="#FF0000" +#SEPARATOR=/ +#PREFIX= +#SUFFIX="B/s" +``` + + +# Options + +The default output is "read / write (k|M)B/s". +If `-R` is not used, the `$BLOCK_INSTANCE` variable, if specified, will be the chosen regex to match against devices. +This allows watching specific devices by e.g. setting `instance=/^sda/` +or `instance=/^sd[ab]/`. + +``` +Usage: disk-io [-t time] [-w width] [-p kB_precision] [-P MB_precision] [-R regex] [-s separator] [-S] [-T threshold [-C warn_color]] [-k|-M] [-l] [-h] +Options: +-L Label to put in front of the text. Default: +-t Time interval in seconds between measurements. Default: 5 +-w The width of printed floats. Default: 4 +-p The precision of kB/s floats. Default: 0 +-P The precision of MB/s floats. Default: 1 +-R Regex that devices must match. Default: /^(s|h)d[a-zA-Z]+/ +-s Separator to put between rates. Default: / +-S Short units, omit B/s in kB/s and MB/s. +-T Rate in kB/s to exceed to trigger a warning. Default: not enabled +-C Color to change the blocklet to warn the user. Default: #FF0000 +-l List devices that iostat reports +-M Do not switch between MB/s and kB/s, use only MB/s +-k Do not switch between MB/s and kB/s, use only kB/s +-h Show this help text +``` diff --git a/.config/i3blocks/disk-io/disk-io b/.config/i3blocks/disk-io/disk-io new file mode 100755 index 0000000..b6bebc2 --- /dev/null +++ b/.config/i3blocks/disk-io/disk-io @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2016 James Murphy +# Licensed under the terms of the GNU GPL v2 only. +# +# i3blocks blocklet script to monitor disk io + +label="${LABEL:-""}" +dt="${DT:-5}" +MB_only="${MB_ONLY:-0}" +kB_only="${KB_ONLY:-0}" +width="${WIDTH:-4}" +MB_precision="${MB_PRECISION:-1}" +kB_precision="${KB_PRECISION:-0}" +regex="${REGEX:-$BLOCK_INSTANCE}" +regex="${regex:-/^(s|h)d[a-zA-Z]+/}" +threshold="${THRESHOLD:-0}" +warn_color="${WARN_COLOR:-#FF0000}" +sep="${SEPARATOR:-/}" +unit_suffix="${SUFFIX:-B/s}" + +function list_devices { + echo "Devices iostat reports that match our regex:" + iostat | awk '$1~/^(s|h)d[a-zA-Z]+/{print $1}' +} + +while getopts L:t:w:p:P:R:s:ST:C:lLMmKkh opt; do + case "$opt" in + L) label="$OPTARG" ;; + t) dt="$OPTARG" ;; + w) width="$OPTARG" ;; + p) kB_precision="$OPTARG" ;; + P) MB_precision="$OPTARG" ;; + R) regex="$OPTARG" ;; + s) sep="$OPTARG" ;; + S) unit_suffix="" ;; + T) threshold="$OPTARG" ;; + C) warn_color="$OPTARG" ;; + l) list_devices; exit 0 ;; + M|m) MB_only=1 ;; + K|k) kB_only=1 ;; + h) printf \ +"Usage: disk-io [-t time] [-w width] [-p kB_precision] [-P MB_precision] [-R regex] [-s separator] [-S] [-T threshold [-C warn_color]] [-k|-M] [-l] [-h] +Options: +-L\tLabel to put in front of the text. Default: $label +-t\tTime interval in seconds between measurements. Default: $dt +-w\tThe width of printed floats. Default: $width +-p\tThe precision of kB/s floats. Default: $kB_precision +-P\tThe precision of MB/s floats. Default: $MB_precision +-R\tRegex that devices must match. Default: $regex +-s\tSeparator to put between rates. Default: $sep +-S\tShort units, omit B/s in kB/s and MB/s. +-T\tRate in kB/s to exceed to trigger a warning. Default: not enabled +-C\tColor to change the blocklet to warn the user. Default: $warn_color +-l\tList devices that iostat reports +-M\tDo not switch between MB/s and kB/s, use only MB/s +-k\tDo not switch between MB/s and kB/s, use only kB/s +-h\tShow this help text +" && exit 0;; + esac +done + +iostat -dyz "$dt" | awk -v sep="$sep" " + BEGIN { + rx = wx = 0; + } + { + if(\$0 == \"\") { + if ($threshold > 0 && (rx >= $threshold || wx >= $threshold)) { + printf \"\"; + } + printf \"$label\"; + if(!$kB_only && ($MB_only || rx >= 1024 || wx >= 1024)) { + printf \"%-$width.${MB_precision}f%s%$width.${MB_precision}f M$unit_suffix\", rx/1024, sep, wx/1024; + } + else { + printf \"%-$width.${kB_precision}f%s%$width.${kB_precision}f k$unit_suffix\", rx, sep, wx; + } + if ($threshold > 0 && (rx >= $threshold || wx >= $threshold)) { + printf \"\"; + } + printf \"\n\"; + fflush(stdout); + } + else if(\$1~/^Device:?/) { + rx = wx = 0; + } + else if(\$1~$regex) { + rx += \$3; + wx += \$4; + } + }" diff --git a/.config/i3blocks/disk-io/disk-io-1.png b/.config/i3blocks/disk-io/disk-io-1.png new file mode 100644 index 0000000..373e1cc Binary files /dev/null and b/.config/i3blocks/disk-io/disk-io-1.png differ diff --git a/.config/i3blocks/disk-io/disk-io-2.png b/.config/i3blocks/disk-io/disk-io-2.png new file mode 100644 index 0000000..f73ed5d Binary files /dev/null and b/.config/i3blocks/disk-io/disk-io-2.png differ diff --git a/.config/i3blocks/disk/README.md b/.config/i3blocks/disk/README.md new file mode 100644 index 0000000..d07c750 --- /dev/null +++ b/.config/i3blocks/disk/README.md @@ -0,0 +1,19 @@ +# disk + +Show disk usage. The directory defaults to $HOME if the instance is not +specified. The script may be called with an optional argument to set the +alert (defaults to 10 for 10%). +The script also accepts the flag `-n` to allow checking the disk usage of network devices, +which is disabled by default. + + +# Config + +``` +[disk] +command=$SCRIPT_DIR/disk +LABEL=HOME +#DIR=$HOME +#ALERT_LOW=10 +interval=30 +``` diff --git a/.config/i3blocks/disk/disk b/.config/i3blocks/disk/disk new file mode 100755 index 0000000..c34240d --- /dev/null +++ b/.config/i3blocks/disk/disk @@ -0,0 +1,48 @@ +#!/bin/sh +# Copyright (C) 2014 Julien Bonjean + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +DIR="${DIR:-$BLOCK_INSTANCE}" +DIR="${DIR:-$HOME}" +ALERT_LOW="${ALERT_LOW:-$1}" +ALERT_LOW="${ALERT_LOW:-10}" # color will turn red under this value (default: 10%) + +LOCAL_FLAG="-l" +if [ "$1" = "-n" ] || [ "$2" = "-n" ]; then + LOCAL_FLAG="" +fi + +df -h -P $LOCAL_FLAG "$DIR" | awk -v label="$LABEL" -v alert_low=$ALERT_LOW ' +/\/.*/ { + # full text + print label $4 + + # short text + print label $4 + + use=$5 + + # no need to continue parsing + exit 0 +} + +END { + gsub(/%$/,"",use) + if (100 - use < alert_low) { + # color + print "#FF0000" + } +} +' diff --git a/.config/i3blocks/disk/disk.png b/.config/i3blocks/disk/disk.png new file mode 100644 index 0000000..76d7ddf Binary files /dev/null and b/.config/i3blocks/disk/disk.png differ diff --git a/.config/i3blocks/disk/i3blocks.conf b/.config/i3blocks/disk/i3blocks.conf new file mode 100644 index 0000000..4295b02 --- /dev/null +++ b/.config/i3blocks/disk/i3blocks.conf @@ -0,0 +1,5 @@ +[disk] +command=$SCRIPT_DIR/disk +LABEL=HOME +#DIR=/mnt/data +interval=30 diff --git a/.config/i3blocks/docker/README.md b/.config/i3blocks/docker/README.md new file mode 100644 index 0000000..c6892d0 --- /dev/null +++ b/.config/i3blocks/docker/README.md @@ -0,0 +1,19 @@ +# docker + +Show the number of running `Docker` containers and latest created container IP address. + +![](docker.jpg) + +# Dependencies + +*docker* + +# Config + +``` +[docker] +command=$SCRIPT_DIR/docker +color=#0db7ed +interval=10 +LABEL=🐳 +``` diff --git a/.config/i3blocks/docker/docker b/.config/i3blocks/docker/docker new file mode 100755 index 0000000..5819cf9 --- /dev/null +++ b/.config/i3blocks/docker/docker @@ -0,0 +1,8 @@ +#!/bin/bash + +# Number of docker containers running +count=$(docker ps -q | wc -l | sed -r 's/^0$//g') +# Recent docker container IP +recent_ip=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $(docker ps -ql)) + +echo "$LABEL$count: $recent_ip" diff --git a/.config/i3blocks/docker/docker.jpg b/.config/i3blocks/docker/docker.jpg new file mode 100644 index 0000000..bff8237 Binary files /dev/null and b/.config/i3blocks/docker/docker.jpg differ diff --git a/.config/i3blocks/docker/i3blocks.conf b/.config/i3blocks/docker/i3blocks.conf new file mode 100644 index 0000000..5a8106a --- /dev/null +++ b/.config/i3blocks/docker/i3blocks.conf @@ -0,0 +1,5 @@ +[docker] +command=$SCRIPT_DIR/docker +color=#0db7ed +interval=10 +LABEL=🐳 diff --git a/.config/i3blocks/email/COPYING b/.config/i3blocks/email/COPYING new file mode 100644 index 0000000..d9a3335 --- /dev/null +++ b/.config/i3blocks/email/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + i3blocks-email + Copyright (C) 2016 Антон Карманов + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + i3blocks-email Copyright (C) 2016 Антон Карманов + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/.config/i3blocks/email/README.md b/.config/i3blocks/email/README.md new file mode 100644 index 0000000..d5b8f77 --- /dev/null +++ b/.config/i3blocks/email/README.md @@ -0,0 +1,100 @@ +# email + +Show the count of new messages in your +email box using IMAP. +Left button mouse click opens custom URL. + +![message](email.png) + +# Dependencies + +Python 3, [python-keyring](https://pypi.python.org/pypi/keyring) (optional), +gnome-keyring (if pyton-keyring using, also you able to use any other +compatible backend) + +**Packages names in Debian based distros**: +python3, python3-keyring, gnome-keyring + +**Packages names in Arch Linux**: +python, python-keyring, gnome-keyring + + +Alternatively you can get python-keyring with +[pip](https://pypi.python.org/pypi/pip): + +```shell +$ pip install keyring +``` + +# Usage + +There are two ways to set up email blocklet. You able to specify options in +**"Settings"** section inside [email](email) file. And if you not allowed to +edit email file, or if you want to use multiple instances of email block, you +could make config file for each instance in **~/.config/i3blocks-email/** +directory. + +Now keep in mind, that there are also two ways to specify your mailbox password. +One way is to past it between apostrophes in PASS line in blocklet or config +file. **It is not secure and it is recommended for debugging only!** + +Another way is to use a system keyring. In this way you should keep PASS empty +as is. To add your password to keyring run: + +```shell +$ $SCRIPT_DIR/email --add $USER +``` +where $USER is your mailbox login. + +**python-keyring and compatible backend should be installed and be in $PATH.** + +You also able to delete key with: +```shell +$ $SCRIPT_DIR/email --remove $USER +``` + + +Now add a section to your i3blocks.conf like following: +```INI +[email] +command=$SCRIPT_DIR/email +interval=300 +min_width=messages: 99 +``` + +If you want to use instance mechanism of i3blocks, you should make config file +in directory **~/.config/i3blocks-email/** with following structure: +```INI +[MAIL] + +HOST: imap.mail_server.com +PORT: 993 +USER: my_mailbox@mail_server.com +PASS: +URL: https://www.mail_server.com + +``` + +The [MAIL] header should exist. Any options are optional and replace the same +options inside [email](email). +The minimal config file is: +```INI +[MAIL] + +HOST: imap.mail_server.com +USER: my_mailbox@mail_server.com +``` + +When config files is created, add an instance option with name of config file +to your i3blocks.conf. Let's imagine, that we have the +~/.config/i3blocks-email/my\_mailbox\_config file, then email section should be: +```ini +[email] +command=$SCRIPT_DIR/email +instance=my_mailbox_config +interval=60 +min_width=messages: 99 +``` + +After configuring blocklet restart your window manager. +New block should appear in the i3bar. diff --git a/.config/i3blocks/email/email b/.config/i3blocks/email/email new file mode 100755 index 0000000..cff8ed5 --- /dev/null +++ b/.config/i3blocks/email/email @@ -0,0 +1,135 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Copyright © 2016 Anton Karmanov + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import configparser +import subprocess +import argparse +import imaplib +from getpass import getpass +import os +try: + import keyring + keyring_loaded = True +except ImportError: + keyring_loaded = False + +# _Settings____________________________________________________________________ + +config = { + 'HOST': 'imap.mail_server.com', + 'PORT': 993, + 'USER': 'my_mailbox@mail_server.com', + 'PASS': '', + 'URL': 'https://www.mail_server.com' +} +# _____________________________________________________________________________ + + +def get_args(): + parser = argparse.ArgumentParser( + description='In interactive mode you able to manage your keys.' + ) + parser.add_argument( + '-a', '--add', type=str, help='add key to keyring' + ) + parser.add_argument( + '-r', '--remove', type=str, help='remove key from keyring' + ) + args = parser.parse_args() + if args.add: + match = False + while not match: + pass_1 = getpass('Type password : ') + pass_2 = getpass('Type password again: ') + if pass_1 == pass_2: + match = True + keyring.set_password('i3blocks-email', args.add, pass_1) + else: + print('\nPasswords do not match!\n') + return(True) + elif args.remove: + ack = input( + 'Are you sure want to delete key for {}? '.format(args.remove) + ) + if ack.lower() in ('y', 'yes'): + keyring.delete_password('i3blocks-email', args.remove) + else: + print('Cancel.') + return(True) + return(False) + + +def parse_instance(): + INSTANCE = '' + try: + INSTANCE = os.environ['BLOCK_INSTANCE'] + except KeyError: + pass + finally: + if len(INSTANCE): + parse_config(INSTANCE) + + +def parse_config(INSTANCE): + global config + HOME = os.environ['HOME'] + config_file = configparser.ConfigParser() + CONFIG_PATH = HOME + '/.config/i3blocks-email/' + INSTANCE + config_file.read(CONFIG_PATH) + for ITEM in config_file['MAIL']: + ITEM = ITEM.upper() + config[ITEM] = config_file['MAIL'][ITEM] + + +def get_PASS(): + return(keyring.get_password('i3blocks-email', config['USER'])) + + +def block_event(): + try: + event = os.environ['BLOCK_BUTTON'] + except KeyError: + event = '0' + if event == '1': + NULL = open(os.devnull, 'w') + subprocess.Popen(['xdg-open', config['URL']], stdout=NULL) + + +def serf(): + box = imaplib.IMAP4_SSL(host=config['HOST'], port=config['PORT']) + box.login(config['USER'], config['PASS']) + box.select() + result, ids = box.search(None, 'UNSEEN') + box.logout() + return(len(ids[0].split())) + + +def printer(new_count): + print(new_count) + print(new_count) + if new_count > 0: + print('#00ff00') + else: + print('#ededed') + +if (keyring_loaded and not get_args()) or not keyring_loaded: + parse_instance() + block_event() + if not config['PASS']: + config['PASS'] = get_PASS() + printer(serf()) diff --git a/.config/i3blocks/email/email.png b/.config/i3blocks/email/email.png new file mode 100644 index 0000000..96c5423 Binary files /dev/null and b/.config/i3blocks/email/email.png differ diff --git a/.config/i3blocks/essid/LICENSE b/.config/i3blocks/essid/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/essid/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/essid/README.md b/.config/i3blocks/essid/README.md new file mode 100644 index 0000000..8b7ab68 --- /dev/null +++ b/.config/i3blocks/essid/README.md @@ -0,0 +1,18 @@ +# essid + +Shows the ESSID that you are connected to. +If no interface is specified, wlan0 is used. +Shows nothing if you are not connected. + +This script depends on `iwconfig`. + +![](essid.png) + +# Config + +``` +[essid] +command=$SCRIPT_DIR/essid +interval=60 +#INTERFACE=wlan0 +``` diff --git a/.config/i3blocks/essid/essid b/.config/i3blocks/essid/essid new file mode 100755 index 0000000..2c3e421 --- /dev/null +++ b/.config/i3blocks/essid/essid @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright (C) 2018 borgified +# Copyright (C) 2014 Alexander Keller + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +#------------------------------------------------------------------------ + +INTERFACE="${INTERFACE:-wlan0}" + +#------------------------------------------------------------------------ + +# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless +# connection (think desktop), the corresponding block should not be displayed. +[[ ! -d /sys/class/net/${INTERFACE}/wireless ]] || + [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && exit + +#------------------------------------------------------------------------ + +ESSID=$(/sbin/iwconfig $INTERFACE | perl -n -e'/ESSID:"(.*?)"/ && print $1') + +#------------------------------------------------------------------------ + +echo $ESSID # full text +echo $ESSID # short text diff --git a/.config/i3blocks/essid/essid.png b/.config/i3blocks/essid/essid.png new file mode 100644 index 0000000..2c726c1 Binary files /dev/null and b/.config/i3blocks/essid/essid.png differ diff --git a/.config/i3blocks/essid/i3blocks.conf b/.config/i3blocks/essid/i3blocks.conf new file mode 100644 index 0000000..c82f04d --- /dev/null +++ b/.config/i3blocks/essid/i3blocks.conf @@ -0,0 +1,4 @@ +[essid] +command=$SCRIPT_DIR/essid +interval=60 +#INTERFACE=wlan0 diff --git a/.config/i3blocks/gpu-load/README.md b/.config/i3blocks/gpu-load/README.md new file mode 100644 index 0000000..a9627ab --- /dev/null +++ b/.config/i3blocks/gpu-load/README.md @@ -0,0 +1,29 @@ +# gpu-load + +Shows load of Nvidia GPUs. + +![](gpu-load.png) + +The four values are the load of the: + +1. The GPU it self +2. The load of the VRAM of the Card +3. Video buffer +4. PCIe bus utilization + +`short_text` only shows the GPU load. + +# Dependencies + +* `nvidia-settings` Note that on Debian-based systems, you have to add `contrib` and `non-free` to your `sources.list` in order to install the package via your package manager. + +# Config +``` +[gpu-load] +command=$SCRIPT_DIR/gpu-load +label=GPU +interval=10 +#min_width=GPU 100% 100% 100% 100% +#T_WARN=70 +#T_CRIT=90 +``` diff --git a/.config/i3blocks/gpu-load/gpu-load b/.config/i3blocks/gpu-load/gpu-load new file mode 100755 index 0000000..4d3ff0d --- /dev/null +++ b/.config/i3blocks/gpu-load/gpu-load @@ -0,0 +1,67 @@ +#! /usr/bin/perl + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +# default values +my $t_warn = $ENV{T_WARN} || 70; +my $t_crit = $ENV{T_CRIT} || 90; +my $gpu_usage = -1; +my $gpu_mem = -1; +my $gpu_video = -1; +my $gpu_pcie = -1; + +sub help { + print "Usage: gpu-load [-w ] [-c ]\n"; + print "-w : warning threshold to become amber\n"; + print "-c : critical threshold to become red\n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit); + +# Get GPU usage from nvidia-settings +open (NVS, 'nvidia-settings -q GPUUtilization -t |') or die; +while () { + if (/^[a-zA-Z]*=(\d+), [a-zA-Z]*=(\d+), [a-zA-Z]*=(\d+), [a-zA-Z]*=(\d+)$/) { + $gpu_usage = $1; + $gpu_mem = $2; + $gpu_video = $3; + $gpu_pcie = $4; + last; + } +} +close(NVS); + +$gpu_usage eq -1 and die 'Can\'t find GPU information'; + +# Print full_text, short_text +printf "%.0f%% %.0f%% %.0f%% %.0f%%\n", $gpu_usage, $gpu_mem, $gpu_video, $gpu_pcie; +printf "%.0f%%\n", $gpu_usage; + +# Print color, if needed +if ($gpu_usage >= $t_crit || $gpu_mem >= $t_crit || $gpu_video >= $t_crit || $gpu_pcie >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($gpu_usage >= $t_warn || $gpu_mem >= $t_warn || $gpu_video >= $t_warn || $gpu_pcie >= $t_warn) { + print "#FFBF00\n"; +} + +exit 0; diff --git a/.config/i3blocks/gpu-load/gpu-load.png b/.config/i3blocks/gpu-load/gpu-load.png new file mode 100644 index 0000000..e7944c7 Binary files /dev/null and b/.config/i3blocks/gpu-load/gpu-load.png differ diff --git a/.config/i3blocks/iface/README.md b/.config/i3blocks/iface/README.md new file mode 100644 index 0000000..e60e7b9 --- /dev/null +++ b/.config/i3blocks/iface/README.md @@ -0,0 +1,24 @@ +# iface + +Show network interface status. +If the instance is not specified, it uses the interface for the default route. +Specify ipv6, ipv4, or either by setting `ADDRESS_FAMILY` to +`inet6`, `inet`, or `inet6?`. + +If an invalid interface is specified, nothing is printed. + + +![](iface-up.png) +![](iface-down.png) + +# Config + +``` +[iface] +command=$SCRIPT_DIR/iface +#LABEL=wlan0: +#IFACE=wlan0 +#ADDRESS_FAMILY=inet6? +color=#00FF00 +interval=10 +``` diff --git a/.config/i3blocks/iface/i3blocks.conf b/.config/i3blocks/iface/i3blocks.conf new file mode 100644 index 0000000..1202a85 --- /dev/null +++ b/.config/i3blocks/iface/i3blocks.conf @@ -0,0 +1,7 @@ +[iface] +command=$SCRIPT_DIR/iface +#LABEL=wlan0: +#IFACE=wlan0 +#ADDRESS_FAMILY=inet6? +color=#00FF00 +interval=10 diff --git a/.config/i3blocks/iface/iface b/.config/i3blocks/iface/iface new file mode 100755 index 0000000..75baa94 --- /dev/null +++ b/.config/i3blocks/iface/iface @@ -0,0 +1,70 @@ +#!/bin/bash +# Copyright (C) 2014 Julien Bonjean +# Copyright (C) 2014 Alexander Keller + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +#------------------------------------------------------------------------ + +# Use the provided interface, otherwise the device used for the default route. +IF="${IFACE:-$BLOCK_INSTANCE}" +IF="${IF:-$(ip route | awk '/^default/ { print $5 ; exit }')}" + +# Exit if there is no default route +[[ -z "$IF" ]] && exit + +#------------------------------------------------------------------------ + +# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless +# connection (think desktop), the corresponding block should not be displayed. +[[ ! -d /sys/class/net/${IF} ]] && exit + +#------------------------------------------------------------------------ + +AF=${ADDRESS_FAMILY:-inet6?} +LABEL="${LABEL:-}" + +for flag in "$1" "$2"; do + case "$flag" in + -4) + AF=inet ;; + -6) + AF=inet6 ;; + -L) + if [[ "$IF" = "" ]]; then + LABEL="iface " + else + LABEL="$IF: " + fi ;; + esac +done + +if [[ "$IF" = "" ]] || [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then + echo "${LABEL}down" # full text + echo "${LABEL}down" # short text + echo \#FF0000 # color + exit +fi + +# if no interface is found, use the first device with a global scope +IPADDR=$(ip addr show $IF | perl -n -e "/$AF ([^ \/]+).* scope global/ && print \$1 and exit") + +case $BLOCK_BUTTON in + 3) echo -n "$IPADDR" | xclip -q -se c ;; +esac + +#------------------------------------------------------------------------ + +echo "$LABEL$IPADDR" # full text +echo "$LABEL$IPADDR" # short text diff --git a/.config/i3blocks/iface/iface-down.png b/.config/i3blocks/iface/iface-down.png new file mode 100644 index 0000000..33a0a72 Binary files /dev/null and b/.config/i3blocks/iface/iface-down.png differ diff --git a/.config/i3blocks/iface/iface-up.png b/.config/i3blocks/iface/iface-up.png new file mode 100644 index 0000000..4ffade6 Binary files /dev/null and b/.config/i3blocks/iface/iface-up.png differ diff --git a/.config/i3blocks/kbdd_layout/LICENSE.md b/.config/i3blocks/kbdd_layout/LICENSE.md new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/.config/i3blocks/kbdd_layout/LICENSE.md @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/.config/i3blocks/kbdd_layout/README.md b/.config/i3blocks/kbdd_layout/README.md new file mode 100644 index 0000000..ebd3cbe --- /dev/null +++ b/.config/i3blocks/kbdd_layout/README.md @@ -0,0 +1,30 @@ +# kbdd_layout + +Show keyboard layout using dbus and [kbdd](https://github.com/qnikst/kbdd). + +![view of block](block.png) + +kbdd is a useful daemon made for lightweight window managers. +It works with xkb and remembers layouts for each window. + +# Requirements + +Dependencies: kbdd (typically in package of the same name). + +You can set your keyboard configuration e.g. with + +``` +exec --no-startup-id "setxkbmap -layout us,ru -option 'grp:ctrl_alt_toggle'" +``` + +in your i3 config. +The blocklet must be restarted if you execute another setxkbmap command, +or it may give incorrect results. + +# Config + +```ini +[kbdd_layout] +command=$SCRIPT_DIR/kbdd_layout +interval=persist +``` diff --git a/.config/i3blocks/kbdd_layout/block.png b/.config/i3blocks/kbdd_layout/block.png new file mode 100644 index 0000000..be66e3f Binary files /dev/null and b/.config/i3blocks/kbdd_layout/block.png differ diff --git a/.config/i3blocks/kbdd_layout/kbdd_layout b/.config/i3blocks/kbdd_layout/kbdd_layout new file mode 100755 index 0000000..96fd4b6 --- /dev/null +++ b/.config/i3blocks/kbdd_layout/kbdd_layout @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# kbdd_layout is a script that parse layout with kbdd in real time +# Copyright (C) 2016 Anton Karmanov +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or any +# later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# In case user is restarting block after making layout changes +# e.g. via setxkbmap, reload kbdd +killall kbdd 2>/dev/null +kbdd >/dev/null || exit 1 + +# Get initial state of layout +N=$( dbus-send --print-reply=literal --dest=ru.gentoo.KbddService\ + /ru/gentoo/KbddService ru.gentoo.kbdd.getCurrentLayout 2>/dev/null |\ + sed -un 's/^.*uint32 //p' ) + +# In case dbus service wasn't available yet, poll until service is ready +while [[ -z "$N" ]]; do + sleep .1 + N=$( dbus-send --print-reply=literal --dest=ru.gentoo.KbddService\ + /ru/gentoo/KbddService ru.gentoo.kbdd.getCurrentLayout 2>/dev/null |\ + sed -un 's/^.*uint32 //p' ) +done +echo $( dbus-send --print-reply=literal --dest=ru.gentoo.KbddService \ + /ru/gentoo/KbddService ru.gentoo.kbdd.getLayoutName uint32:$N ) + +# Parse dbus output +dbus-monitor "interface='ru.gentoo.kbdd',member='layoutNameChanged'" |\ + sed -un '0~2p' | sed -un 's:.*string "\(.*\)".*:\1:p' | sed -u '/:/d' diff --git a/.config/i3blocks/kernel/kernel b/.config/i3blocks/kernel/kernel new file mode 100755 index 0000000..827d3e4 --- /dev/null +++ b/.config/i3blocks/kernel/kernel @@ -0,0 +1,7 @@ +#!/bin/sh + +latest=$(curl -s https://www.kernel.org/releases.json | jq -r '.latest_stable.version') +if ! uname -r | grep $latest > /dev/null; then + echo outdated + notify-send 'New kernel update' "v$latest available" +fi diff --git a/.config/i3blocks/key_layout/README.md b/.config/i3blocks/key_layout/README.md new file mode 100644 index 0000000..db41e50 --- /dev/null +++ b/.config/i3blocks/key_layout/README.md @@ -0,0 +1,18 @@ +# key_layout + +Display the current keyboard layout using setxkbmap. + +![](key_layout.png) + +![](key_layout_variant.png) + +# Installation + +Use the following in your i3blocks config: + +```ini +[key_layout] +command=$SCRIPT_DIR/key_layout +label=Layout +interval=30 +``` diff --git a/.config/i3blocks/key_layout/key_layout b/.config/i3blocks/key_layout/key_layout new file mode 100755 index 0000000..a861534 --- /dev/null +++ b/.config/i3blocks/key_layout/key_layout @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Copyright 2016 Patrick Haun +# Edited: Denis Kadyshev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +setxkbmap -query | awk ' + BEGIN{layout="";variant=""} + /^layout/{layout=$2} + /^variant/{variant=" ("$2")"} + END{printf("%s%s",layout,variant)}' diff --git a/.config/i3blocks/key_layout/key_layout.png b/.config/i3blocks/key_layout/key_layout.png new file mode 100644 index 0000000..d6e2104 Binary files /dev/null and b/.config/i3blocks/key_layout/key_layout.png differ diff --git a/.config/i3blocks/key_layout/key_layout_variant.png b/.config/i3blocks/key_layout/key_layout_variant.png new file mode 100644 index 0000000..a5a7bf1 Binary files /dev/null and b/.config/i3blocks/key_layout/key_layout_variant.png differ diff --git a/.config/i3blocks/keyindicator/README.md b/.config/i3blocks/keyindicator/README.md new file mode 100644 index 0000000..d71ad57 --- /dev/null +++ b/.config/i3blocks/keyindicator/README.md @@ -0,0 +1,53 @@ +# keyindicator + +Show the status of capslock or numlock. + +![](keyindicator-active.png) + +![](keyindicator-inactive.png) + +# Installation + +Add the following bindings to i3 config file: + +``` +bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks +bindsym --release Num_Lock exec pkill -SIGRTMIN+11 i3blocks +``` + +Use the following in your i3blocks config file: + +``` ini +[keyindicator] +command=$SCRIPT_DIR/keyindicator +#Allowed keys are CAPS and NUM +KEY=CAPS +markup=pango +interval=once +signal=11 +#COLOR_ON=#00FF00 +#COLOR_OFF=#222222 +#BG_COLOR_ON= +#BG_COLOR_OFF= + +[keyindicator] +command=$SCRIPT_DIR/keyindicator +KEY=NUM +markup=pango +interval=once +signal=11 +#COLOR_ON=#00FF00 +HIDE_WHEN_OFF=1 +``` + +# Options + +``` +Usage: keyindicator [-c ] [-C ] [-b ] [-B ] [--hide] + -c : hex color to use when indicator is on + -C : hex color to use when indicator is off + -b : hex color to use when indicator is on + -B : hex color to use when indicator is off + --hide: don't output anything when indicator is off + +``` diff --git a/.config/i3blocks/keyindicator/keyindicator b/.config/i3blocks/keyindicator/keyindicator new file mode 100755 index 0000000..50c3a3f --- /dev/null +++ b/.config/i3blocks/keyindicator/keyindicator @@ -0,0 +1,89 @@ +#!/usr/bin/env perl +# +# Copyright 2014 Marcelo Cerri +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use warnings; +use utf8; +use Getopt::Long; +use File::Basename; + +# Default values +my $indicator = $ENV{BLOCK_INSTANCE} || $ENV{KEY} || "CAPS"; +my $color_on = $ENV{COLOR_ON} || "#00FF00"; +my $color_off = $ENV{COLOR_OFF} || "#222222"; +my $bg_color_on = $ENV{BG_COLOR_ON}; +my $bg_color_off = $ENV{BG_COLOR_OFF}; +my $hide = $ENV{HIDE_WHEN_OFF} || 0; + +sub help { + my $program = basename($0); + printf "Usage: %s [-c ] [-C ] [-b ] [-B ] [--hide]\n", $program; + printf " -c : hex color to use when indicator is on\n"; + printf " -C : hex color to use when indicator is off\n"; + printf " -b : hex color to use when indicator is on\n"; + printf " -B : hex color to use when indicator is off\n"; + printf " --hide: don't output anything when indicator is off\n"; + printf "\n"; + printf "Note: environment variable \$BLOCK_INSTANCE should be one of:\n"; + printf " CAPS, NUM (default is CAPS).\n"; + exit 0; +} + +Getopt::Long::config qw(no_ignore_case); +GetOptions("help|h" => \&help, + "c=s" => \$color_on, + "C=s" => \$color_off, + "b=s" => \$bg_color_on, + "B=s" => \$bg_color_off, + "hide" => \$hide) or exit 1; + +# Key mapping +my %indicators = ( + CAPS => 0x00000001, + NUM => 0x00000002, +); + +# Retrieve key flags +my $mask = 0; +open(XSET, "xset -q |") or die; +while () { + if (/LED mask:\s*([0-9a-f]+)/) { + $mask = hex $1; + last; + } +} +close(XSET); + +# Determine if indicator is on or off +my $indicator_status = ($indicators{$indicator} || 0) & $mask; + +# Exit if --hide and indicator is off +if ($hide and !$indicator_status) { + exit 0 +} + +# Output +my $fg_color = $indicator_status ? $color_on : $color_off; +my $bg_color = $indicator_status ? $bg_color_on : $bg_color_off; + +if (defined $bg_color) { + printf "%s\n", $fg_color, $bg_color, $indicator; +} else { + printf "%s\n", $fg_color, $indicator; +} + +exit 0 diff --git a/.config/i3blocks/keyindicator/keyindicator-active.png b/.config/i3blocks/keyindicator/keyindicator-active.png new file mode 100644 index 0000000..2023bbf Binary files /dev/null and b/.config/i3blocks/keyindicator/keyindicator-active.png differ diff --git a/.config/i3blocks/keyindicator/keyindicator-inactive.png b/.config/i3blocks/keyindicator/keyindicator-inactive.png new file mode 100644 index 0000000..5076ca0 Binary files /dev/null and b/.config/i3blocks/keyindicator/keyindicator-inactive.png differ diff --git a/.config/i3blocks/kubernetes/README.md b/.config/i3blocks/kubernetes/README.md new file mode 100644 index 0000000..d76f565 --- /dev/null +++ b/.config/i3blocks/kubernetes/README.md @@ -0,0 +1,17 @@ +# kubernetes + +Show the kubernetes current context and namespace in use. This is usefull when you are operating multiple kube clusters and/or namespaces. + +![](kubernetes.png) + +# Dependencies + +*kubectl* must be install and accessible under your *$PATH* + +# Config + +``` +[kubernetes] +command=$SCRIPT_DIR/kubernetes +interval=10 +``` diff --git a/.config/i3blocks/kubernetes/i3blocks.conf b/.config/i3blocks/kubernetes/i3blocks.conf new file mode 100644 index 0000000..534fa8f --- /dev/null +++ b/.config/i3blocks/kubernetes/i3blocks.conf @@ -0,0 +1,3 @@ +[kubernetes] +command=$SCRIPT_DIR/kubernetes +interval=10 diff --git a/.config/i3blocks/kubernetes/kubernetes b/.config/i3blocks/kubernetes/kubernetes new file mode 100755 index 0000000..f04efff --- /dev/null +++ b/.config/i3blocks/kubernetes/kubernetes @@ -0,0 +1,10 @@ +#!/bin/bash +KCONTEXT=$(kubectl config current-context 2>/dev/null) +if [[ $?=="0" ]]; then + CC=$(kubectl config view -ojsonpath='{..current-context}') + KNAMESPACE=$(kubectl config view -ojsonpath="{.Contexts[?(@.Name==\"$CC\")]..namespace}") + echo "☸ $KCONTEXT/$KNAMESPACE ☸" + echo "☸ $KCONTEXT/$KNAMESPACE ☸" + echo \#4040FF # color +fi + diff --git a/.config/i3blocks/kubernetes/kubernetes.png b/.config/i3blocks/kubernetes/kubernetes.png new file mode 100644 index 0000000..abdc304 Binary files /dev/null and b/.config/i3blocks/kubernetes/kubernetes.png differ diff --git a/.config/i3blocks/load_average/README.md b/.config/i3blocks/load_average/README.md new file mode 100644 index 0000000..7d7f632 --- /dev/null +++ b/.config/i3blocks/load_average/README.md @@ -0,0 +1,13 @@ +# load_average + +Show the system 1 minute load average. + +![](load_average.png) + +# Config + +``` +[load_average] +command=$SCRIPT_DIR/load_average +interval=10 +``` diff --git a/.config/i3blocks/load_average/i3blocks.conf b/.config/i3blocks/load_average/i3blocks.conf new file mode 100644 index 0000000..d979ec5 --- /dev/null +++ b/.config/i3blocks/load_average/i3blocks.conf @@ -0,0 +1,3 @@ +[load_average] +command=$SCRIPT_DIR/load_average +interval=10 diff --git a/.config/i3blocks/load_average/load_average b/.config/i3blocks/load_average/load_average new file mode 100755 index 0000000..37a5c71 --- /dev/null +++ b/.config/i3blocks/load_average/load_average @@ -0,0 +1,34 @@ +#!/bin/sh +# Copyright (C) 2014 Julien Bonjean + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +load="$(cut -d ' ' -f1 /proc/loadavg)" +cpus="$(nproc)" + +# full text +echo "$load" + +# short text +echo "$load" + +# color if load is too high +awk -v cpus=$cpus -v cpuload=$load ' + BEGIN { + if (cpus <= cpuload) { + print "#FF0000"; + exit 33; + } + } +' diff --git a/.config/i3blocks/load_average/load_average.png b/.config/i3blocks/load_average/load_average.png new file mode 100644 index 0000000..8d575bf Binary files /dev/null and b/.config/i3blocks/load_average/load_average.png differ diff --git a/.config/i3blocks/mediaplayer/README.md b/.config/i3blocks/mediaplayer/README.md new file mode 100644 index 0000000..921d94e --- /dev/null +++ b/.config/i3blocks/mediaplayer/README.md @@ -0,0 +1,36 @@ +# mediaplayer + +Generic media player status/controls. + +![Example screenshot](mediaplayer.png) + +This displays "ARTIST - SONG" if music is playing. By +left-clicking/right-clicking the displayed text, it will play the previous/next +song. Middle-clicking will pause/unpause the song. + +Supported players are: +- spotify, vlc, audacious, xmms2, mplayer and others that +use MPRIS DBus Interface Specification +- mpd +- cmus +- rhythmbox + +mpd is supported through mpc (music player client). + +For MPRIS support you need to have playerctl binary in your path. +See: https://github.com/acrisci/playerctl + +If you leave the instance empty it will try to find an +active player used on it's own. + +# Installation + +Add the following to your i3blocks config: + +``` ini +[mediaplayer] +command=$SCRIPT_DIR/mediaplayer +instance=spotify +interval=5 +signal=10 +``` diff --git a/.config/i3blocks/mediaplayer/mediaplayer b/.config/i3blocks/mediaplayer/mediaplayer new file mode 100755 index 0000000..f78bd78 --- /dev/null +++ b/.config/i3blocks/mediaplayer/mediaplayer @@ -0,0 +1,156 @@ +#!/usr/bin/env perl +# Copyright (C) 2014 Tony Crisci +# Copyright (C) 2015 Thiago Perrotta + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Requires playerctl binary to be in your path (except cmus) +# See: https://github.com/acrisci/playerctl + +# Set instance=NAME in the i3blocks configuration to specify a music player +# (playerctl will attempt to connect to org.mpris.MediaPlayer2.[NAME] on your +# DBus session). + +use Time::HiRes qw(usleep); +use Env qw(BLOCK_INSTANCE); + +use constant DELAY => 50; # Delay in ms to let network-based players (spotify) reflect new data. +use constant SPOTIFY_STR => 'spotify'; + +my @metadata = (); +my $player_arg = ""; + +if ($BLOCK_INSTANCE) { + $player_arg = "--player='$BLOCK_INSTANCE'"; +} + +sub buttons { + my $method = shift; + + if($method eq 'mpd') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("mpc prev"); + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("mpc toggle"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("mpc next"); + } elsif ($ENV{'BLOCK_BUTTON'} == 4) { + system("mpc volume +10"); + } elsif ($ENV{'BLOCK_BUTTON'} == 5) { + system("mpc volume -10"); + } + } elsif ($method eq 'cmus') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("cmus-remote --prev"); + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("cmus-remote --pause"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("cmus-remote --next"); + } + } elsif ($method eq 'playerctl') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("playerctl $player_arg previous"); + usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR; + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("playerctl $player_arg play-pause"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("playerctl $player_arg next"); + usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR; + } elsif ($ENV{'BLOCK_BUTTON'} == 4) { + system("playerctl $player_arg volume 0.01+"); + } elsif ($ENV{'BLOCK_BUTTON'} == 5) { + system("playerctl $player_arg volume 0.01-"); + } + } elsif ($method eq 'rhythmbox') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("rhythmbox-client --previous"); + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("rhythmbox-client --play-pause"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("rhythmbox-client --next"); + } + } +} + +sub cmus { + my @cmus = split /^/, qx(cmus-remote -Q); + if ($? == 0) { + foreach my $line (@cmus) { + my @data = split /\s/, $line; + if (shift @data eq 'tag') { + my $key = shift @data; + my $value = join ' ', @data; + + @metadata[0] = $value if $key eq 'artist'; + @metadata[1] = $value if $key eq 'title'; + } + } + + if (@metadata) { + buttons('cmus'); + + # metadata found so we are done + print(join ' - ', @metadata); + exit 0; + } + } +} + +sub mpd { + my $data = qx(mpc current); + if (not $data eq '') { + buttons("mpd"); + print($data); + exit 0; + } +} + +sub playerctl { + buttons('playerctl'); + + my $artist = qx(playerctl $player_arg metadata artist); + chomp $artist; + # exit status will be nonzero when playerctl cannot find your player + exit(0) if $? || $artist eq '(null)'; + + push(@metadata, $artist) if $artist; + + my $title = qx(playerctl $player_arg metadata title); + exit(0) if $? || $title eq '(null)'; + + push(@metadata, $title) if $title; + + print(join(" - ", @metadata)) if @metadata; +} + +sub rhythmbox { + buttons('rhythmbox'); + + my $data = qx(rhythmbox-client --print-playing --no-start); + print($data); +} + +if ($player_arg eq '' or $player_arg =~ /mpd/) { + mpd; +} +elsif ($player_arg =~ /cmus/) { + cmus; +} +elsif ($player_arg =~ /rhythmbox/) { + rhythmbox; +} +else { + playerctl; +} +print("\n"); diff --git a/.config/i3blocks/mediaplayer/mediaplayer.png b/.config/i3blocks/mediaplayer/mediaplayer.png new file mode 100644 index 0000000..40e89fa Binary files /dev/null and b/.config/i3blocks/mediaplayer/mediaplayer.png differ diff --git a/.config/i3blocks/memory/README.md b/.config/i3blocks/memory/README.md new file mode 100644 index 0000000..4578dd1 --- /dev/null +++ b/.config/i3blocks/memory/README.md @@ -0,0 +1,20 @@ +# memory + +Show memory usage. Accepts instance "mem" or "swap". + +![](memory.png) + +# Config + +``` +[memory] +command=$SCRIPT_DIR/memory +label=MEM +interval=30 + +#[memory] +#command=$SCRIPT_DIR/memory +#label=SWAP +#instance=swap +#interval=30 +``` diff --git a/.config/i3blocks/memory/i3blocks.conf b/.config/i3blocks/memory/i3blocks.conf new file mode 100644 index 0000000..0a86f04 --- /dev/null +++ b/.config/i3blocks/memory/i3blocks.conf @@ -0,0 +1,11 @@ +[memory] +command=$SCRIPT_DIR/memory +label=MEM +interval=30 + +#[memory] +#command=$SCRIPT_DIR/memory +#label=SWAP +#instance=swap +#interval=30 + diff --git a/.config/i3blocks/memory/memory b/.config/i3blocks/memory/memory new file mode 100755 index 0000000..90eb2c6 --- /dev/null +++ b/.config/i3blocks/memory/memory @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright (C) 2014 Julien Bonjean + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +TYPE="${BLOCK_INSTANCE:-mem}" + +awk -v type=$TYPE ' +/^MemTotal:/ { + mem_total=$2 +} +/^MemFree:/ { + mem_free=$2 +} +/^Buffers:/ { + mem_free+=$2 +} +/^Cached:/ { + mem_free+=$2 +} +/^SwapTotal:/ { + swap_total=$2 +} +/^SwapFree:/ { + swap_free=$2 +} +END { + if (type == "swap") { + free=swap_free/1024/1024 + used=(swap_total-swap_free)/1024/1024 + total=swap_total/1024/1024 + } else { + free=mem_free/1024/1024 + used=(mem_total-mem_free)/1024/1024 + total=mem_total/1024/1024 + } + + pct=0 + if (total > 0) { + pct=used/total*100 + } + + # full text + printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct) + + # short text + printf("%.f%%\n", pct) + + # color + if (pct > 90) { + print("#FF0000") + } else if (pct > 80) { + print("#FFAE00") + } else if (pct > 70) { + print("#FFF600") + } +} +' /proc/meminfo diff --git a/.config/i3blocks/memory/memory.png b/.config/i3blocks/memory/memory.png new file mode 100644 index 0000000..c918a05 Binary files /dev/null and b/.config/i3blocks/memory/memory.png differ diff --git a/.config/i3blocks/monitor_manager/LICENSE b/.config/i3blocks/monitor_manager/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/monitor_manager/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/monitor_manager/README.md b/.config/i3blocks/monitor_manager/README.md new file mode 100644 index 0000000..0ce2911 --- /dev/null +++ b/.config/i3blocks/monitor_manager/README.md @@ -0,0 +1,36 @@ +# monitor_manager + +Quickly manage your monitors. +This script supports: on/off, blank/unblank, +extend, clone, set primary, change output mode, +rotate, reflect, adjust brightness. + +![](monitor_manager.png) + +# Dependencies + +python3, python3-tk, xrandr, fontawesome (fonts-font-awesome package), arandr suggested but not required. + +# Usage + +Add the following to your i3blocks config: + +``` +[monitors] +command=$SCRIPT_DIR/monitor_manager +interval=once +#SHOW_ON_OFF=1 +#SHOW_NAMES=1 +#SHOW_PRIMARY=1 +#SHOW_MODE=1 +#SHOW_BLANKED=1 +#SHOW_DUPLICATE=1 +#SHOW_ROTATION=1 +#SHOW_REFLECTION=1 +#SHOW_BRIGHTNESS=1 +#SHOW_BRIGHTNESS_VALUE=0 +#SHOW_UP_DOWN=1 +#FONT_FAMILY=DejaVu Sans Mono +#FONT_SIZE=11 +#CLOSE_TO_BOUNDARY_BUFFER=20 +``` diff --git a/.config/i3blocks/monitor_manager/monitor_manager b/.config/i3blocks/monitor_manager/monitor_manager new file mode 100755 index 0000000..143e244 --- /dev/null +++ b/.config/i3blocks/monitor_manager/monitor_manager @@ -0,0 +1,728 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2016 James Murphy +# Licensed under the GPL version 2 only +# +# monitor_manager is an i3blocks blocklet script to quickly manage your +# connected output devices + + +from tkinter import * +from tkinter import messagebox +from shutil import which +import tkinter.font as font +from subprocess import call, check_output, CalledProcessError +import re +import os + +DESKTOP_SYMBOL = "\uf108" + +UP_ARROW = "\uf062" +DOWN_ARROW = "\uf063" +UNBLANKED_SYMBOL = "\uf06e" +BLANKED_SYMBOL = "\uf070" +NOT_CLONED_SYMBOL = "\uf096" +PRIMARY_SYMBOL = "\uf005" +SECONDARY_SYMBOL = "\uf006" +CLONED_SYMBOL = "\uf24d" +ROTATION_NORMAL = "\uf151" +ROTATION_LEFT = "\uf191" +ROTATION_RIGHT = "\uf152" +ROTATION_INVERTED = "\uf150" +REFLECTION_NORMAL = "\uf176" +REFLECTION_X = "\uf07e" +REFLECTION_Y = "\uf07d" +REFLECTION_XY = "\uf047" +TOGGLE_ON = "\uf205" +TOGGLE_OFF = "\uf204" +APPLY_SYMBOL = "\uf00c" +CANCEL_SYMBOL = "\uf00d" +ARANDR_SYMBOL = "\uf085" +REFRESH_SYMBOL = "\uf021" + +strbool = lambda s: s.lower() in ['t', 'true', '1'] +def _default(name, default='', arg_type=strbool): + val = default + if name in os.environ: + val = os.environ[name] + return arg_type(val) + + +SHOW_ON_OFF = _default("SHOW_ON_OFF","1") +SHOW_NAMES = _default("SHOW_NAMES", "1") +SHOW_PRIMARY = _default("SHOW_PRIMARY", "1") +SHOW_MODE = _default("SHOW_MODE", "1") +SHOW_BLANKED = _default("SHOW_BLANKED", "1") +SHOW_DUPLICATE = _default("SHOW_DUPLICATE", "1") +SHOW_ROTATION = _default("SHOW_ROTATION", "1") +SHOW_REFLECTION = _default("SHOW_REFLECTION", "1") +SHOW_BRIGHTNESS = _default("SHOW_BRIGHTNESS", "1") +SHOW_BRIGHTNESS_VALUE = _default("SHOW_BRIGHTNESS_VALUE", "0") +SHOW_UP_DOWN = _default("SHOW_UP_DOWN", "1") + +FONTAWESOME_FONT_FAMILY = "FontAwesome" +FONTAWESOME_FONT_SIZE = 11 +FONTAWESOME_FONT = (FONTAWESOME_FONT_FAMILY, FONTAWESOME_FONT_SIZE) +DEFAULT_FONT_FAMILY = _default("FONT_FAMILY","DejaVu Sans Mono", str) +DEFAULT_FONT_SIZE = _default("FONT_SIZE", 11, int) +DEFAULT_FONT = (DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE) + +BRIGHTNESS_SLIDER_HANDLE_LENGTH = 20 +BRIGHTNESS_SLIDER_WIDTH = 15 +BRIGHTNESS_SLIDER_LENGTH = 50 + +WINDOW_CLOSE_TO_BOUNDARY_BUFFER = _default("CLOSE_TO_BOUNDARY_BUFFER", 20, int) + +class Output: + def __init__(self, name=None, w=None, h=None, x=None, y=None, rate=None, + active=False, primary=False, sameAs=None, blanked=False, rotation="normal", + reflection="normal", brightness=1.0): + self.name = name + self.w = w + self.h = h + self.x = x + self.y = y + self.rate = rate + self.active = active + self.primary = primary + self.sameAs = sameAs + self.blanked = blanked + self.modes = [] + self.currentModeIndex = None + self.preferredModeIndex = None + self.row = None + self.rotation = rotation + self.reflection = reflection + self.brightness = brightness + + def setPreferredMode(self): + if self.preferredModeIndex != None: + self.setMode(self.preferredModeIndex) + elif self.modes != None: + self.setMode(0) + + def setMode(self, index): + self.w, self.h, self.rate = self.modes[index] + self.currentModeIndex = index + + def realOutputs(): + outputs = [] + xrandrText = check_output(["xrandr","--verbose"],universal_newlines=True) + outputBlocks = re.split(r'\n(?=\S)', xrandrText, re.MULTILINE) + infoPattern = re.compile( + r'^(\S+)' # output name + ' connected ' # must be connected + '(primary )?' # check if primary output + '((\d+)x(\d+)\+(\d+)\+(\d+) )?' # width x height + xoffset + yoffset + '(\(\S+\) )?' # mode code (0x4a) + '(normal|left|inverted|right)? ?' # rotation + '(X axis|Y axis|X and Y axis)?') # reflection + brightnessPattern = re.compile(r'^\tBrightness: ([\d.]+)', re.MULTILINE) + modePattern = re.compile(r'^ (\d+)x(\d+)[^\n]*?\n +h:[^\n]*?\n +v:[^\n]*?([\d.]+)Hz$', re.MULTILINE) + for outputBlock in outputBlocks: + output = Output() + infoMatch = infoPattern.match(outputBlock) + if infoMatch: + output.name = infoMatch.group(1) + if infoMatch.group(2): + output.primary = True + if infoMatch.group(3): + output.active = True + output.w, output.h, output.x, output.y = map(int,infoMatch.group(4, 5, 6, 7)) + if infoMatch.group(9): + output.rotation = infoMatch.group(9) + if output.rotation in ["left", "right"]: + output.w, output.h = output.h, output.w + if infoMatch.group(10): + if infoMatch.group(10) == "X axis": + output.reflection = "x" + elif infoMatch.group(10) == "Y axis": + output.reflection = "y" + elif infoMatch.group(10) == "X and Y axis": + output.reflection = "xy" + else: + output.reflection = "normal" + else: + output.reflection = "normal" + brightnessMatch = brightnessPattern.search(outputBlock) + if brightnessMatch: + try: + brightness = float(brightnessMatch.group(1)) + output.brightness = brightness + if abs(brightness) < 1e-09: + output.blanked = True + except ValueError: + pass + modeMatches = modePattern.finditer(outputBlock) + for i, modeMatch in enumerate(modeMatches): + if "*current" in modeMatch.group(0): + output.currentModeIndex = i + output.rate = modeMatch.group(3) + if "+preferred" in modeMatch.group(0): + output.preferredModeIndex = i + output.modes.append(modeMatch.group(1,2,3)) + outputs.append(output) + outputs.sort(key=lambda m: m.x if m.x != None else -1) + prev = None + for output in outputs: + if prev != None and output.active and prev.active and output.x == prev.x: + output.sameAs = prev.name + else: + prev = output + + return outputs + + def modestr(mode): + return "{}x{}@{}".format(*mode) + + def status(self): + if self.active: + if self.sameAs == None or self.sameAs == self.name: + if self.w and self.h and self.rate: + return "{}x{}@{}".format(self.w, self.h, self.rate) + else: + return "auto" + else: + return "duplicate {}".format(self.sameAs) + else: + return "Inactive" + + + def __str__(self): + return "{} {}x{}+{}+{} active:{}, primary:{}\nmodes:{}\ncurrentIndex:{} preferredIndex:{}".format( + self.name, self.w, self.h, self.x, self.y, self.active, self.primary, self.modes, self.currentModeIndex, self.preferredModeIndex) + +class MonitorManager(): + def __init__(self, root): + self.root = root + self.root.withdraw() + self.root.resizable(0,0) + self.root.wm_title("Monitor Manager") + self.frame = None + self.outputs = [] + self.hardRefreshList() + style = {'relief':FLAT, 'padx':1, 'pady':1, 'anchor':'w', 'font':FONTAWESOME_FONT} + + self.infoLabel = Label(self.root, text="", **style) + self.infoLabel.config(font=DEFAULT_FONT) + + self.bottomRow = [] + + self.applyButton = Button(self.root, text=APPLY_SYMBOL, **style) + self.bottomRow.append(self.applyButton) + + self.refreshButton = Button(self.root, text=REFRESH_SYMBOL, **style) + self.bottomRow.append(self.refreshButton) + + if which("arandr"): + self.arandrButton = Button(self.root, text=ARANDR_SYMBOL, **style) + self.bottomRow.append(self.arandrButton) + else: + self.arandrButton = None + + self.cancelButton = Button(self.root, text=CANCEL_SYMBOL, **style) + self.bottomRow.append(self.cancelButton) + + self.infoLabel.grid(row=1,column=0, columnspan=len(self.bottomRow)) + self.gridRow(2, self.bottomRow) + + self.moveToMouse() + self.root.deiconify() + + def registerBindings(self): + self.root.bind("", self.handleApply) + self.root.bind("", self.handleCancel) + + self.applyButton.bind("", self.handleApply) + self.setInfo(self.applyButton, "Apply changes") + + self.refreshButton.bind("", self.hardRefreshList) + self.setInfo(self.refreshButton, "Refresh list") + + if self.arandrButton: + self.arandrButton.bind("", self.handleArandr) + self.setInfo(self.arandrButton, "Launch aRandR") + + self.cancelButton.bind("", self.handleCancel) + self.setInfo(self.cancelButton, "Cancel") + + for toggleButton in self.toggleButtons: + toggleButton.bind("", self.toggleActive) + toggleButton.bind("", self.handleUp) + toggleButton.bind("", self.handleDown) + self.setInfo(toggleButton, "Turn output on/off") + + for primaryButton in self.primaryButtons: + primaryButton.bind("", self.setPrimary) + self.setInfo(primaryButton, "Set primary output") + + for blankedButton in self.blankedButtons: + blankedButton.bind("", self.toggleBlanked) + self.setInfo(blankedButton, "Show/hide output") + + for duplicateButton in self.duplicateButtons: + duplicateButton.bind("", self.toggleDuplicate) + self.setInfo(duplicateButton, "Duplicate another output") + + for rotateButton in self.rotateButtons: + rotateButton.bind("", self.cycleRotation) + self.setInfo(rotateButton, "Rotate output") + + for reflectButton in self.reflectButtons: + reflectButton.bind("", self.cycleReflection) + self.setInfo(reflectButton, "Reflect output") + + for brightnessSlider in self.brightnessSliders: + brightnessSlider.bind("", self.updateBrightness) + self.setInfo(brightnessSlider, "Adjust brightness") + + for upButton in self.upButtons: + upButton.bind("", self.handleUp) + upButton.bind("", self.handleUp) + upButton.bind("", self.handleDown) + self.setInfo(upButton, "Move up") + + for downButton in self.downButtons: + downButton.bind("", self.handleDown) + downButton.bind("", self.handleUp) + downButton.bind("", self.handleDown) + self.setInfo(downButton, "Move down") + + def gridRow(self, row, widgets): + column = 0 + for w in widgets: + w.grid(row=row, column=column) + column += 1 + + def moveToMouse(self): + root = self.root + root.update_idletasks() + width = root.winfo_reqwidth() + height = root.winfo_reqheight() + x = root.winfo_pointerx() - width//2 + y = root.winfo_pointery() - height//2 + screen_width = root.winfo_screenwidth() + screen_height = root.winfo_screenheight() + if x+width > screen_width - WINDOW_CLOSE_TO_BOUNDARY_BUFFER: + x = screen_width - WINDOW_CLOSE_TO_BOUNDARY_BUFFER - width + elif x < WINDOW_CLOSE_TO_BOUNDARY_BUFFER: + x = WINDOW_CLOSE_TO_BOUNDARY_BUFFER + if y+height > screen_height - WINDOW_CLOSE_TO_BOUNDARY_BUFFER: + y = screen_height - WINDOW_CLOSE_TO_BOUNDARY_BUFFER - height + elif y < WINDOW_CLOSE_TO_BOUNDARY_BUFFER: + y = WINDOW_CLOSE_TO_BOUNDARY_BUFFER + + root.geometry('+{}+{}'.format(x, y)) + + def setInfo(self, widget, info): + widget.bind("", lambda e: self.infoLabel.config(text=info, fg="black")) + widget.bind("", lambda e: self.infoLabel.config(text="")) + + def handleApply(self, e=None): + self.root.after_idle(self.doHandleApply) + + def doHandleApply(self): + if not self.getUserConfirmationIfDangerousConfiguration(): + return + command = ["xrandr"] + if not self.existsPrimary(): + command += ["--noprimary"] + partition = self.sameAsPartition() + prevFirstActive = None + for p in partition: + firstActive = None + for output in p: + command += ["--output", output.name] + if output.active: + if firstActive == None: + firstActive = output + else: + command += ["--same-as", firstActive.name] + if output.primary: + command += ["--primary"] + if prevFirstActive != None: + command += ["--right-of", prevFirstActive.name] + if output.w != None and output.h != None and output.rate != None: + command += ["--mode", "{}x{}".format(output.w,output.h)] + command += ["--rate", output.rate ] + else: + command += ["--auto"] + command += ["--brightness", str(output.brightness)] + command += ["--rotate", output.rotation] + command += ["--reflect", output.reflection] + else: + command += ["--off"] + if firstActive: + prevFirstActive = firstActive + self.root.after_idle(lambda: self.executeXrandrCommand(command)) + + def executeXrandrCommand(self, command): + try: + check_output(command, universal_newlines=True) + except CalledProcessError as err: + self.infoLabel.config(text="xrandr returned nonzero exit status {}".format(err.returncode), fg="red") + + def getUserConfirmationIfDangerousConfiguration(self): + result = "yes" + if all(map(lambda o: o.blanked or not o.active, self.outputs)): + result = messagebox.askquestion("All blanked or off", + "All ouputs are set to be turned off or blanked, continue?", + icon="warning") + return result == "yes" + + def sameAsPartition(self): + partition = [] + for output in self.outputs: + place = None + for p in partition: + if place != None: + break; + for o in p: + if place == None and (output.sameAs == o.name or o.sameAs == output.name): + place = p + break; + if place: + place.append(output) + else: + partition.append([output]) + return partition + + + def handleCancel(self, e=None): + self.root.destroy() + + def handleArandr(self, e=None): + call(["i3-msg", "-q", "exec", "arandr"]) + self.root.destroy() + + def handleUp(self, e): + row = e.widget.output.row + if row > 0: + self.swapOutputRows(row-1, row) + self.softRefreshList() + + def handleDown(self, e): + row = e.widget.output.row + n = len(self.outputs) + if row + 1 < n: + self.swapOutputRows(row, row+1) + self.softRefreshList() + + def swapOutputRows(self, row1, row2): + outputs = self.outputs + outputs[row1],outputs[row2] = outputs[row2],outputs[row1] + outputs[row1].row = row1 + outputs[row2].row = row2 + for widget in self.frame.grid_slaves(row=row2): + widget.output = outputs[row2] + for widget in self.frame.grid_slaves(row=row1): + widget.output = outputs[row1] + + def setPrimary(self, e): + output = e.widget.output + output.primary = not output.primary + for otherOutput in self.outputs: + if otherOutput != output: + otherOutput.primary = False + self.softRefreshList() + + def existsPrimary(self): + for output in self.outputs: + if output.primary: + return True + return False + + def toggleActive(self, e): + output = e.widget.output + output.active = not output.active + if output.active: + output.setPreferredMode() + else: + for otherOutput in self.outputs: + if otherOutput.sameAs == output.name: + otherOutput.sameAs = None + self.softRefreshList() + + def toggleBlanked(self, e): + output = e.widget.output + if output.blanked: + output.blanked = False + output.brightness = 1.0 + else: + output.blanked = True + output.brightness = 0.0 + self.softRefreshList() + + def updateBrightness(self, e): + output = e.widget.output + output.brightness = .01 * e.widget.get() + output.blanked = False + if abs(output.brightness) < 1e-09: + output.blanked = True + self.softRefreshList() + + def cycleRotation(self, e): + output = e.widget.output + if output.rotation == "normal": + output.rotation = "right" + elif output.rotation == "right": + output.rotation = "inverted" + elif output.rotation == "inverted": + output.rotation = "left" + else: + output.rotation = "normal" + self.softRefreshList() + + def rotationSymbol(self, rotation): + return { + "normal": ROTATION_NORMAL, + "left": ROTATION_LEFT, + "right": ROTATION_RIGHT, + "inverted": ROTATION_INVERTED, + }[rotation] + + def cycleReflection(self, e): + output = e.widget.output + if output.reflection == "normal": + output.reflection = "x" + elif output.reflection == "x": + output.reflection = "y" + elif output.reflection == "y": + output.reflection = "xy" + else: + output.reflection = "normal" + self.softRefreshList() + + def reflectionSymbol(self, reflection): + return { + "normal": REFLECTION_NORMAL, + "x": REFLECTION_X, + "y": REFLECTION_Y, + "xy": REFLECTION_XY, + }[reflection] + + def toggleDuplicate(self, e): + duplicateButton = e.widget + optionMenu = duplicateButton.statusOptionMenu + output = optionMenu.output + if output.sameAs != None: + output.sameAs = None + self.setMenuToOutput(optionMenu, output) + else: + self.setMenuToDuplicate(optionMenu) + self.softRefreshList() + + def getDuplicableOutputsFor(self, output): + return [o for o in self.outputs if o != output and o.sameAs == None] + + def softRefreshList(self, e=None): + for widget in set().union(self.nameLabels, self.primaryButtons, + self.statusOptionMenus, self.blankedButtons, + self.duplicateButtons, self.rotateButtons, self.reflectButtons, + self.brightnessSliders, self.upButtons, self.downButtons): + widget.config(fg="gray" if not widget.output.active else "black") + + for widget in self.toggleButtons: + widget.config(text=TOGGLE_ON if widget.output.active else TOGGLE_OFF) + + for widget in self.nameLabels: + widget.config(text=widget.output.name) + + for widget in self.primaryButtons: + widget.config(text=PRIMARY_SYMBOL if widget.output.primary else SECONDARY_SYMBOL) + if not widget.output.primary: + widget.config(fg="gray") + + for widget in self.statusOptionMenus: + widget.config(text=widget.output.status()) + if widget.output.sameAs != None: + self.setMenuToDuplicate(widget) + self.setInfo(widget, "Select output to duplicate") + else: + self.setMenuToOutput(widget, widget.output) + self.setInfo(widget, "Select output mode") + + for widget in self.blankedButtons: + widget.config(text=BLANKED_SYMBOL if widget.output.blanked else UNBLANKED_SYMBOL) + + for widget in self.duplicateButtons: + widget.config(text=CLONED_SYMBOL if widget.output.sameAs else NOT_CLONED_SYMBOL) + + for widget in self.rotateButtons: + widget.config(text=self.rotationSymbol(widget.output.rotation)) + + for widget in self.reflectButtons: + widget.config(text=self.reflectionSymbol(widget.output.reflection)) + + for widget in self.brightnessSliders: + widget.set(int(100*widget.output.brightness)) + + def hardRefreshList(self, e=None): + self.outputs = Output.realOutputs() + self.root.after_idle(self.populateGrid) + + def populateGrid(self): + oldFrame = self.frame + self.frame = Frame(self.root) + self.frame.grid(row=0, column=0, columnspan=len(self.bottomRow)) + self.toggleButtons = [] + self.nameLabels = [] + self.primaryButtons = [] + self.statusOptionMenus = [] + self.blankedButtons = [] + self.duplicateButtons = [] + self.rotateButtons = [] + self.reflectButtons = [] + self.brightnessSliders = [] + self.upButtons = [] + self.downButtons = [] + for row, output in enumerate(self.outputs): + self.makeLabelRow(output, row) + self.registerBindings() + if oldFrame: + oldFrame.destroy() + + def makeLabelRow(self, output, row): + output.row = row + style = {'relief':FLAT, 'padx':1, 'pady':1, 'anchor':'w'} + widgets = [] + + toggleButton = Button(self.frame, font=FONTAWESOME_FONT, **style) + toggleButton.output = output + self.toggleButtons.append(toggleButton) + if SHOW_ON_OFF: + widgets.append(toggleButton) + + nameLabel = Label(self.frame, font=DEFAULT_FONT) + nameLabel.output = output + self.nameLabels.append(nameLabel) + if SHOW_NAMES: + widgets.append(nameLabel) + + primaryButton = Button(self.frame, font=FONTAWESOME_FONT, **style) + primaryButton.output = output + self.primaryButtons.append(primaryButton) + if not output.primary: + primaryButton.config(fg="gray") + if SHOW_PRIMARY: + widgets.append(primaryButton) + + var = StringVar(self.frame) + statusOptionMenu = OptionMenu(self.frame, var, None) + statusOptionMenu.output = output + statusOptionMenu.var = var + statusOptionMenu.config(relief=FLAT) + self.statusOptionMenus.append(statusOptionMenu) + if SHOW_MODE or SHOW_DUPLICATE: + widgets.append(statusOptionMenu) + + blankedButton = Button(self.frame, font=FONTAWESOME_FONT, **style) + blankedButton.output = output + self.blankedButtons.append(blankedButton) + if SHOW_BLANKED: + widgets.append(blankedButton) + + duplicateButton = Button(self.frame, font=FONTAWESOME_FONT, **style) + duplicateButton.statusOptionMenu = statusOptionMenu + duplicateButton.output = output + self.duplicateButtons.append(duplicateButton) + if SHOW_DUPLICATE: + widgets.append(duplicateButton) + + rotateButton = Button(self.frame, font=FONTAWESOME_FONT, **style) + rotateButton.output = output + self.rotateButtons.append(rotateButton) + if SHOW_ROTATION: + widgets.append(rotateButton) + + reflectButton = Button(self.frame, font=FONTAWESOME_FONT, **style) + reflectButton.output = output + self.reflectButtons.append(reflectButton) + if SHOW_REFLECTION: + widgets.append(reflectButton) + + brightnessSlider = Scale(self.frame, orient="horizontal", from_=0, to=100, + length=BRIGHTNESS_SLIDER_LENGTH, showvalue=SHOW_BRIGHTNESS_VALUE, + sliderlength=BRIGHTNESS_SLIDER_HANDLE_LENGTH, + width=BRIGHTNESS_SLIDER_WIDTH, font=FONTAWESOME_FONT) + brightnessSlider.output = output + self.brightnessSliders.append(brightnessSlider) + if SHOW_BRIGHTNESS: + widgets.append(brightnessSlider) + + upButton = Button(self.frame, text=UP_ARROW, font=FONTAWESOME_FONT, **style) + upButton.output = output + self.upButtons.append(upButton) + if SHOW_UP_DOWN: + widgets.append(upButton) + + downButton = Button(self.frame, text=DOWN_ARROW, font=FONTAWESOME_FONT, **style) + downButton.output = output + self.downButtons.append(downButton) + if SHOW_UP_DOWN: + widgets.append(downButton) + + for widget in widgets: + widget.output = output + self.gridRow(row, widgets) + self.softRefreshList() + + def setMenuToOutput(self, optionMenu, output): + menu = optionMenu["menu"] + var = optionMenu.var + modes = output.modes + menu.delete(0, END) + for i, mode in enumerate(modes): + label = Output.modestr(mode) + menu.add_command(label=label, command=setLabelAndOutputModeFunc(var,label,output,i)) + if output.currentModeIndex != None: + var.set(Output.modestr(modes[output.currentModeIndex])) + elif output.preferredModeIndex != None: + var.set(Output.modestr(modes[output.preferredModeIndex])) + elif len(modes) > 0: + var.set(Output.modestr(modes[0])) + + def setMenuToDuplicate(self, optionMenu): + menu = optionMenu["menu"] + var = optionMenu.var + output = optionMenu.output + menu.delete(0, END) + duplicables = self.getDuplicableOutputsFor(output) + defaultIndex = 0 + for i,otherOutput in enumerate(duplicables): + label = otherOutput.name + menu.add_command(label=label, command=setLabelAndSameAsFunc(var,label,output)) + if label == output.sameAs: + defaultIndex = i + if len(duplicables) > 0: + var.set(menu.entrycget(defaultIndex, "label")) + output.sameAs = menu.entrycget(defaultIndex, "label") + else: + var.set("None") + + def handleFocusOut(self, event): + self.root.destroy() + +def setLabelAndOutputModeFunc(var, label, output, i): + def func(): + var.set(label) + output.setMode(i) + return func + +def setLabelAndSameAsFunc(var, sameAs, output): + def func(): + var.set(sameAs) + output.sameAs = sameAs + return func + +if os.environ.get('BLOCK_BUTTON') == "1": + if os.fork() != 0: + root = Tk() + if DEFAULT_FONT_FAMILY and DEFAULT_FONT_SIZE: + font.nametofont("TkDefaultFont").config(family=DEFAULT_FONT_FAMILY, size=DEFAULT_FONT_SIZE) + manager = MonitorManager(root) + root.mainloop() + else: + print(DESKTOP_SYMBOL) +else: + print(DESKTOP_SYMBOL) diff --git a/.config/i3blocks/monitor_manager/monitor_manager.png b/.config/i3blocks/monitor_manager/monitor_manager.png new file mode 100644 index 0000000..34d0a3c Binary files /dev/null and b/.config/i3blocks/monitor_manager/monitor_manager.png differ diff --git a/.config/i3blocks/monitor_manager/monitor_manager.py b/.config/i3blocks/monitor_manager/monitor_manager.py new file mode 120000 index 0000000..831e97e --- /dev/null +++ b/.config/i3blocks/monitor_manager/monitor_manager.py @@ -0,0 +1 @@ +monitor_manager \ No newline at end of file diff --git a/.config/i3blocks/nm-vpn/LICENCE b/.config/i3blocks/nm-vpn/LICENCE new file mode 100644 index 0000000..9bb4ce8 --- /dev/null +++ b/.config/i3blocks/nm-vpn/LICENCE @@ -0,0 +1,25 @@ +Copyright 2018 Stephen Gregoratto + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/.config/i3blocks/nm-vpn/README.md b/.config/i3blocks/nm-vpn/README.md new file mode 100644 index 0000000..f1f9dca --- /dev/null +++ b/.config/i3blocks/nm-vpn/README.md @@ -0,0 +1,37 @@ +# nm-vpn + +Parses output from `nmcli` to show the current connected VPN name/status + +![](images/full.png) + +![](images/short.png) + +# Requirements + + - NetworkManager/`nmcli` + - `sh` + - `awk` + - tested on nawk, gawk, mawk, [goawk](https://github.com/benhoyt/goawk), Plan 9 awk and busybox awk. + +# Usage + +`nm-vpn` gets active connection info from `nmcli` for interface `tun0`. +A VPN connection in NetworkManager is established only when `tun0` is +active, thus the blocklet’s response time depends on how long it takes +to connect. + +## Output + +When `tun0` is active, `nm-vpn` will print in the following form: + - Full: `VPN: "Name"` + - Short: `ON` + +In addition, each form will be coloured green (“\#00FF00”). + +# Config + +``` ini +[nm-vpn] +label=VPN: +interval=5 +``` diff --git a/.config/i3blocks/nm-vpn/i3blocks.conf b/.config/i3blocks/nm-vpn/i3blocks.conf new file mode 100644 index 0000000..832fe81 --- /dev/null +++ b/.config/i3blocks/nm-vpn/i3blocks.conf @@ -0,0 +1,5 @@ +[nm-vpn] +label=VPN: +interval=5 + +# vim: syntax=dosini diff --git a/.config/i3blocks/nm-vpn/images/full.png b/.config/i3blocks/nm-vpn/images/full.png new file mode 100644 index 0000000..165ee40 Binary files /dev/null and b/.config/i3blocks/nm-vpn/images/full.png differ diff --git a/.config/i3blocks/nm-vpn/images/short.png b/.config/i3blocks/nm-vpn/images/short.png new file mode 100644 index 0000000..6b9e93a Binary files /dev/null and b/.config/i3blocks/nm-vpn/images/short.png differ diff --git a/.config/i3blocks/nm-vpn/nm-vpn b/.config/i3blocks/nm-vpn/nm-vpn new file mode 100755 index 0000000..7c98fd5 --- /dev/null +++ b/.config/i3blocks/nm-vpn/nm-vpn @@ -0,0 +1,4 @@ +#!/bin/sh +nmcli -t connection show --active | awk -F ':' ' +/tun0/{vpn="ON"} /vpn/{name=$1} +END{if(vpn) printf("%s\n%s\n%s\n", name, vpn, "#00FF00")}' diff --git a/.config/i3blocks/openvpn/README.md b/.config/i3blocks/openvpn/README.md new file mode 100644 index 0000000..868d872 --- /dev/null +++ b/.config/i3blocks/openvpn/README.md @@ -0,0 +1,25 @@ +# openvpn + +Support multiple VPN, with colors. + +# Usage + +Add the following to your i3blocks config: + +``` ini +[openvpn] +command=$SCRIPT_DIR/openvpn +interval=20 +PID_FILE_FORMAT='/run/openvpn/*.pid' +``` + +Note: devices in configuration file should be named with their number (ex: tun0, tap1), +as dynamic devices are not supported. +Also make sure that your openvpn config filename ends in `.conf`. + +# Options + +``` +Usage: openvpn [-p pid_file_format] +-p : format string to glob all pid files (default '/run/openvpn/*.pid') +``` diff --git a/.config/i3blocks/openvpn/openvpn b/.config/i3blocks/openvpn/openvpn new file mode 100755 index 0000000..c5fe9df --- /dev/null +++ b/.config/i3blocks/openvpn/openvpn @@ -0,0 +1,158 @@ +#!/usr/bin/env perl +# Made by Pierre Mavro/Deimosfr +# Minor contribution by Thor K. H. +# Licensed under the terms of the GNU GPL v3, or any later version. +# Version: 0.3 + +# Usage: +# 1. The configuration name of OpenVPN should be familiar for you (home,work...) +# 2. The device name in your configuration file should be fully named (tun0,tap1...not only tun or tap) +# 3. When you launch one or multiple OpenVPN connexion, be sure the PID file is written in the correct folder (ex: --writepid /run/openvpn/home.pid) + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +my $openvpn_enabled='/dev/shm/openvpn_i3blocks_enabled'; +my $openvpn_disabled='/dev/shm/openvpn_i3blocks_disabled'; + +# Print output +sub print_output { + my $ref_pid_files = shift; + my @pid_files = @$ref_pid_files; + my $change=0; + + # Total pid files + my $total_pid = @pid_files; + if ($total_pid == 0) { + print "down\n"x2; + # Delete OpenVPN i3blocks temp files + if (-f $openvpn_enabled) { + unlink $openvpn_enabled or die "Can't delete $openvpn_enabled\n"; + # Colorize if VPN has just went down + print '#FF0000\n'; + } + unless (-f $openvpn_disabled) { + open(my $shm, '>', $openvpn_disabled) or die "Can't write $openvpn_disabled\n"; + } + exit(0); + } + + # Check if interface device is present + my $vpn_found=0; + my $pid; + my $cmd_line; + my @config_name; + my @config_path; + my $interface; + my $config_prefix; + my $current_config_path; + my $current_config_name; + foreach (@pid_files) { + # Get current PID + $pid=0; + open(PID, '<', $_); + while() { + chomp $_; + $pid = $_; + } + close(PID); + # Check if PID has been found + if ($pid ==0) { + print "Can't get PID $_: $!\n"; + } + + # Check if PID is still alive + $cmd_line='/proc/'.$pid.'/cmdline'; + if (-f $cmd_line) { + # Get config name + open(CMD_LINE, '<', $cmd_line); + while() { + chomp $_; + $config_prefix = ""; + if ($_ =~ /--cd\x{00}(.*?)\x{00}/) { + $config_prefix = $1; + } + if ($_ =~ /--config\x{00}(.*?\.conf)\x{00}/) { + # Get interface from config file + $current_config_path = $1; + # Remove unwanted escape chars + $interface = 'null'; + # Get configuration name + if ($current_config_path =~ /(\w+).conf/) { + $current_config_name=$1; + } else { + $current_config_name='unknown'; + } + + $current_config_path = "$config_prefix/$current_config_path"; + + # Get OpenVPN interface device name + open(CONFIG, '<', $current_config_path) or die "Can't read config file '$current_config_path': $!\n"; + while() { + chomp $_; + if ($_ =~ /dev\s+(\w+)/) { + $interface=$1; + last; + } + } + close(CONFIG); + # check if interface exist + unless ($interface eq 'null') { + if (-d "/sys/class/net/$interface") { + push @config_name, $current_config_name; + $vpn_found=1; + # Write enabled file + unless (-f $openvpn_enabled) { + open(my $shm, '>', $openvpn_enabled) or die "Can't write $openvpn_enabled\n"; + $change=1; + } + } + } + } + } + close(CMD_LINE); + } + } + + # Check if PID found + my $names; + my $short_status; + if ($vpn_found == 1) { + $names = join('/', @config_name); + $short_status='up'; + } else { + $short_status='down'; + $names = $short_status; + } + + print "$names\n"; + print "$short_status\n"; + + # Print color if there were changes + print "#00FF00\n" if ($change == 1); + + exit(0); +} + +sub check_opts { + # Vars + my $pid_file_format=$ENV{PID_FILE_FORMAT} || '/run/openvpn/*.pid'; + + # Set options + GetOptions( "help|h" => \&help, + "p=s" => \$pid_file_format); + + my @pid_file=glob $pid_file_format; + print_output(\@pid_file); +} + +sub help { + print "Usage: openvpn [-p pid_file_format]\n"; + print "-p : format string to glob all pid files (default '/run/openvpn/*.pid)'\n"; + print "Note: devices in configuration file should be named with their number (ex: tun0, tap1)\n"; + exit(1); +} + +&check_opts; diff --git a/.config/i3blocks/rofi-calendar/README.md b/.config/i3blocks/rofi-calendar/README.md new file mode 100644 index 0000000..1fa748e --- /dev/null +++ b/.config/i3blocks/rofi-calendar/README.md @@ -0,0 +1,28 @@ +# rofi-calendar + +Have a minimal calendar pop up in rofi when clicking the date blocklet (right click to show next month) + +![](screenshot.png) + +![](screenshot2.png) + +# Dependencies + +* rofi +* cal from util-linux package, supporting --color=always +# Installation + +* Copy the script into your directory of choice, e.g. ~/.i3blocks/blocklets +* Give it execution permission (`chmod +x rofi-calendar`) +* Edit rofi launch options in the script to fit your needs +* Add the following blocklet to your i3blocks.conf: + +```ini +[rofi-calendar] +command=$SCRIPT_DIR/rofi-calendar +interval=3600 +LABEL= +#DATEFTM=+%a. %d. %b. %Y +#SHORTFTM=+%d.%m.%Y +``` + diff --git a/.config/i3blocks/rofi-calendar/rofi-calendar b/.config/i3blocks/rofi-calendar/rofi-calendar new file mode 100755 index 0000000..d4f2ec2 --- /dev/null +++ b/.config/i3blocks/rofi-calendar/rofi-calendar @@ -0,0 +1,40 @@ +#! /bin/sh + +DATEFTM="${DATEFTM:-+%a. %d. %b. %Y}" +SHORTFMT="${SHORTFMT:-+%d.%m.%Y}" +LABEL="${LABEL:-}" +blockdate=$(date "$DATEFTM") +shortblockdate=$(date "$SHORTFMT") + +year=$(date '+%Y') +month=$(date '+%m') +case "$BLOCK_BUTTON" in + 1|2) + date=$(date '+%A, %d. %B');; + 3) + (( month == 12 )) && month=1 && year=$((year + 1)) || month=$((month + 1)) + date=$(cal $month $year | sed -n '1s/^ *//;1s/ *$//p') +esac +case "$BLOCK_BUTTON" in + 1|2|3) +export TERM=xterm +cal --color=always $month $year \ + | sed 's/\x1b\[[7;]*m/\\/g' \ + | sed 's/\x1b\[[27;]*m/\<\/u\>\<\/b\>/g' \ + | tail -n +2 \ + | rofi \ + -dmenu \ + -markup-rows \ + -no-fullscreen \ + -font "Monospace 6" \ + -hide-scrollbar \ + -bw 2 \ + -m -3 \ + -theme-str '#window {anchor:southeast; location: northwest;}' \ + -eh 1 \ + -width -22 \ + -no-custom \ + -p "$date" > /dev/null + esac +echo "$LABEL$blockdate" +echo "$LABEL$shortblockdate" diff --git a/.config/i3blocks/rofi-calendar/screenshot.png b/.config/i3blocks/rofi-calendar/screenshot.png new file mode 100644 index 0000000..1516eb1 Binary files /dev/null and b/.config/i3blocks/rofi-calendar/screenshot.png differ diff --git a/.config/i3blocks/rofi-calendar/screenshot2.png b/.config/i3blocks/rofi-calendar/screenshot2.png new file mode 100644 index 0000000..5963bea Binary files /dev/null and b/.config/i3blocks/rofi-calendar/screenshot2.png differ diff --git a/.config/i3blocks/shutdown_menu/README.md b/.config/i3blocks/shutdown_menu/README.md new file mode 100644 index 0000000..3f72bb7 --- /dev/null +++ b/.config/i3blocks/shutdown_menu/README.md @@ -0,0 +1,54 @@ +# shutdown_menu + +Use rofi or zenity to change the system's runstate thanks to systemd. + +The script can be used to shutdown, reboot, logout, lock etc. +It is inspired from an example in [i3pystatus' Wiki][i3pystatus]. + +![](rofi.png) + +![](zenity.png) + +# Requirements + +- `systemd`, +- `rofi` or `zenity`, +- shell with associative array support. + +# Usage + +``` +[shutdown_menu] +full_text=Quit +# If you are using FontAwesome, we recommend the power-off icon: +# http://fontawesome.io/icon/power-off/ +command=$SCRIPT_DIR/shutdown_menu +#FG_COLOR=#bbbbbb +#BG_COLOR=#111111 +#HLFG_COLOR=#111111 +#HLBG_COLOR=#bbbbbb +#BORDER_COLOR=#222222 +#ROFI_TEXT=Menu: +#ROFI_OPTIONS=-width 11 -location 3 -hide-scrollbar -bw 2 +#ZENITY_TITLE=Menu +#ZENITY_TEXT=Action: +#ZENITY_OPTIONS=--column= --hide-header +#ENABLE_CONFIRMATIONS=true (must be true or false) +#LAUNCHER=rofi (must be rofi or zenity) +#LOCKSCRIPT=i3lock --color=${BG_COLOR#"#"} +``` + +Since `rofi` and `zenity` have mouse support, this can be integrated in +i3blocks with a clickable block. It can also be used directly from i3, for +instance: + +``` +bindsym Control+Mod1+Delete exec $SCRIPTDIR/shutdown_menu +``` + +For the i3blocks label to use, we recommend FontAwesome's +[power-off][power-off] icon. + + +[i3pystatus]: https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu +[power-off]: http://fontawesome.io/icon/power-off diff --git a/.config/i3blocks/shutdown_menu/i3blocks.conf b/.config/i3blocks/shutdown_menu/i3blocks.conf new file mode 100644 index 0000000..8c6bb82 --- /dev/null +++ b/.config/i3blocks/shutdown_menu/i3blocks.conf @@ -0,0 +1,18 @@ +[shutdown_menu] +full_text=Quit +# If you are using FontAwesome, we recommend the power-off icon: +# http://fontawesome.io/icon/power-off/ +command=$SCRIPT_DIR/shutdown_menu +#FG_COLOR=#bbbbbb +#BG_COLOR=#111111 +#HLFG_COLOR=#111111 +#HLBG_COLOR=#bbbbbb +#BORDER_COLOR=#222222 +#ROFI_TEXT=Menu: +#ROFI_OPTIONS=-width 11 -location 3 -hide-scrollbar -bw 2 +#ZENITY_TITLE=Menu +#ZENITY_TEXT=Action: +#ZENITY_OPTIONS=--column= --hide-header +#ENABLE_CONFIRMATIONS=true (must be true or false) +#LAUNCHER=rofi (must be rofi or zenity) +#LOCKSCRIPT=i3lock --color=${BG_COLOR#"#"} diff --git a/.config/i3blocks/shutdown_menu/rofi.png b/.config/i3blocks/shutdown_menu/rofi.png new file mode 100644 index 0000000..a4068bc Binary files /dev/null and b/.config/i3blocks/shutdown_menu/rofi.png differ diff --git a/.config/i3blocks/shutdown_menu/shutdown_menu b/.config/i3blocks/shutdown_menu/shutdown_menu new file mode 100755 index 0000000..3949d6f --- /dev/null +++ b/.config/i3blocks/shutdown_menu/shutdown_menu @@ -0,0 +1,186 @@ +#!/usr/bin/env bash +# +# Use rofi/zenity to change system runstate thanks to systemd. +# +# Note: this currently relies on associative array support in the shell. +# +# Inspired from i3pystatus wiki: +# https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu +# +# Copyright 2015 Benjamin Chrétien +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +####################################################################### +# BEGIN CONFIG # +####################################################################### + +# Use a custom lock script +#LOCKSCRIPT="i3lock-extra -m pixelize" + +# Colors: FG (foreground), BG (background), HL (highlighted) +FG_COLOR="${FG_COLOR:-#bbbbbb}" +BG_COLOR="${BG_COLOR:-#111111}" +HLFG_COLOR="${HLFG_COLOR:-#111111}" +HLBG_COLOR="${HLBG_COLOR:-#bbbbbb}" +BORDER_COLOR="${BORDER_COLOR:-#222222}" + +# Options not related to colors +ROFI_TEXT="${ROFI_TEXT:-Menu:}" +ROFI_OPTIONS=(${ROFI_OPTIONS:--width 11 -location 3 -hide-scrollbar -bw 2}) + +# Zenity options +ZENITY_TITLE="${ZENITY_TITLE:-Menu}" +ZENITY_TEXT="${ZENITY_TEXT:-Action:}" +ZENITY_OPTIONS=(${ZENITY_OPTIONS:---column= --hide-header}) + +####################################################################### +# END CONFIG # +####################################################################### + +# Whether to ask for user's confirmation +enable_confirmation=${ENABLE_CONFIRMATIONS:-false} + +# Preferred launcher if both are available +preferred_launcher="${LAUNCHER:-rofi}" + +usage="$(basename "$0") [-h] [-c] [-p name] -- display a menu for shutdown, reboot, lock etc. + +where: + -h show this help text + -c ask for user confirmation + -p preferred launcher (rofi or zenity) + +This script depends on: + - systemd, + - i3, + - rofi or zenity." + +# Check whether the user-defined launcher is valid +launcher_list=(rofi zenity) +function check_launcher() { + if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then + echo "Supported launchers: ${launcher_list[*]}" + exit 1 + else + # Get array with unique elements and preferred launcher first + # Note: uniq expects a sorted list, so we cannot use it + i=1 + launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \ + | sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' ')) + fi +} + +# Parse CLI arguments +while getopts "hcp:" option; do + case "${option}" in + h) echo "${usage}" + exit 0 + ;; + c) enable_confirmation=true + ;; + p) preferred_launcher="${OPTARG}" + check_launcher "${preferred_launcher}" + ;; + *) exit 1 + ;; + esac +done +check_launcher "${preferred_launcher}" + +# Check whether a command exists +function command_exists() { + command -v "$1" &> /dev/null 2>&1 +} + +# systemctl required +if ! command_exists systemctl ; then + exit 1 +fi + +# menu defined as an associative array +typeset -A menu + +# Menu with keys/commands +menu=( + [Shutdown]="systemctl poweroff" + [Reboot]="systemctl reboot" + [Hibernate]="systemctl hibernate" + [Suspend]="systemctl suspend" + [Halt]="systemctl halt" + [Lock]="${LOCKSCRIPT:-i3lock --color=${BG_COLOR#"#"}}" + [Logout]="i3-msg exit" + [Cancel]="" +) +menu_nrows=${#menu[@]} + +# Menu entries that may trigger a confirmation message +menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout" + +launcher_exe="" +launcher_options="" +rofi_colors="" + +function prepare_launcher() { + if [[ "$1" == "rofi" ]]; then + rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \ + -hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}") + launcher_exe="rofi" + launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \ + "${rofi_colors[@]}" "${ROFI_OPTIONS[@]}") + elif [[ "$1" == "zenity" ]]; then + launcher_exe="zenity" + launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \ + "${ZENITY_OPTIONS[@]}") + fi +} + +for l in "${launcher_list[@]}"; do + if command_exists "${l}" ; then + prepare_launcher "${l}" + break + fi +done + +# No launcher available +if [[ -z "${launcher_exe}" ]]; then + exit 1 +fi + +launcher=(${launcher_exe} "${launcher_options[@]}") +selection="$(printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}")" + +function ask_confirmation() { + if [ "${launcher_exe}" == "rofi" ]; then + confirmed=$(echo -e "Yes\nNo" | rofi -dmenu -i -lines 2 -p "${selection}?" \ + "${rofi_colors[@]}" "${ROFI_OPTIONS[@]}") + [ "${confirmed}" == "Yes" ] && confirmed=0 + elif [ "${launcher_exe}" == "zenity" ]; then + zenity --question --text "Are you sure you want to ${selection,,}?" + confirmed=$? + fi + + if [ "${confirmed}" == 0 ]; then + i3-msg -q "exec ${menu[${selection}]}" + fi +} + +if [[ $? -eq 0 && ! -z ${selection} ]]; then + if [[ "${enable_confirmation}" = true && \ + ${menu_confirm} =~ (^|[[:space:]])"${selection}"($|[[:space:]]) ]]; then + ask_confirmation + else + i3-msg -q "exec ${menu[${selection}]}" + fi +fi diff --git a/.config/i3blocks/shutdown_menu/zenity.png b/.config/i3blocks/shutdown_menu/zenity.png new file mode 100644 index 0000000..7d7620b Binary files /dev/null and b/.config/i3blocks/shutdown_menu/zenity.png differ diff --git a/.config/i3blocks/tahoe-lafs/LICENSE b/.config/i3blocks/tahoe-lafs/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/tahoe-lafs/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/tahoe-lafs/README.md b/.config/i3blocks/tahoe-lafs/README.md new file mode 100644 index 0000000..2717944 --- /dev/null +++ b/.config/i3blocks/tahoe-lafs/README.md @@ -0,0 +1,22 @@ +# tahoe-lafs + +Check on the status of your tahoe-lafs grid. + +![](tahoe-lafs.png) + +# Requirements + +Dependencies: bash, curl, jq, tahoe-lafs (unless using a remote node) + +# Usage + +Copy the `i3blocks.conf` section into your i3blocks configuration. +The `node.url` of a node in the grid you want the status of should be set as the `instance` +variable to the blocklet. + +``` +[tahoe-lafs] +command=$SCRIPT_DIR/tahoe-lafs +instance=localhost:3456 +interval=3600 +``` diff --git a/.config/i3blocks/tahoe-lafs/i3blocks.conf b/.config/i3blocks/tahoe-lafs/i3blocks.conf new file mode 100644 index 0000000..4c4b29d --- /dev/null +++ b/.config/i3blocks/tahoe-lafs/i3blocks.conf @@ -0,0 +1,4 @@ +[tahoe-lafs] +command=$SCRIPT_DIR/tahoe-lafs +instance=localhost:3456 +interval=3600 diff --git a/.config/i3blocks/tahoe-lafs/tahoe-lafs b/.config/i3blocks/tahoe-lafs/tahoe-lafs new file mode 100755 index 0000000..1457c80 --- /dev/null +++ b/.config/i3blocks/tahoe-lafs/tahoe-lafs @@ -0,0 +1,22 @@ +#!/bin/bash + +NODE_URL=${BLOCK_INSTANCE%/} +DISK_AVAIL=$(curl -s "$NODE_URL/statistics?t=json" 2>/dev/null| jq -r '.stats."storage_server.disk_avail"') + +if [[ -n "$DISK_AVAIL" ]] && [[ "$DISK_AVAIL" != "null" ]]; then + DISK_AVAIL=$(echo "$DISK_AVAIL" | awk ' + { + GB=$1/1024/1024/1024 + if(GB<1000){ + printf "%.1fG\n", GB + } + else{ + printf "%.1fT\n", GB/1024 + } + }') + echo "tahoe: $DISK_AVAIL" +else + echo "tahoe down" + echo "tahoe down" + echo "#FF0000" +fi diff --git a/.config/i3blocks/tahoe-lafs/tahoe-lafs.png b/.config/i3blocks/tahoe-lafs/tahoe-lafs.png new file mode 100644 index 0000000..cfa4d44 Binary files /dev/null and b/.config/i3blocks/tahoe-lafs/tahoe-lafs.png differ diff --git a/.config/i3blocks/temperature/README.md b/.config/i3blocks/temperature/README.md new file mode 100644 index 0000000..fe0a010 --- /dev/null +++ b/.config/i3blocks/temperature/README.md @@ -0,0 +1,21 @@ +# temperature + +Show system temperatures. + +![](temperature.png) + +# Dependencies + +* `lm-sensors` + +# Usage + +``` ini +[temperature] +command=$SCRIPT_DIR/temperature +label=TEMP +interval=10 +#T_WARN=70 +#T_CRIT=90 +#SENSOR_CHIP="" +``` diff --git a/.config/i3blocks/temperature/temperature b/.config/i3blocks/temperature/temperature new file mode 100755 index 0000000..2170f10 --- /dev/null +++ b/.config/i3blocks/temperature/temperature @@ -0,0 +1,69 @@ +#!/usr/bin/env perl +# Copyright 2014 Pierre Mavro +# Copyright 2014 Vivien Didelot +# Copyright 2014 Andreas Guldstrand +# Copyright 2014 Benjamin Chretien + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use warnings; +use utf8; +use Getopt::Long; + +binmode(STDOUT, ":utf8"); + +# default values +my $t_warn = $ENV{T_WARN} || 70; +my $t_crit = $ENV{T_CRIT} || 90; +my $chip = $ENV{SENSOR_CHIP} || ""; +my $temperature = -9999; + +sub help { + print "Usage: temperature [-w ] [-c ] [--chip ]\n"; + print "-w : warning threshold to become yellow\n"; + print "-c : critical threshold to become red\n"; + print "--chip : sensor chip\n"; + exit 0; +} + +GetOptions("help|h" => \&help, + "w=i" => \$t_warn, + "c=i" => \$t_crit, + "chip=s" => \$chip); + +# Get chip temperature +open (SENSORS, "sensors -u $chip |") or die; +while () { + if (/^\s+temp1_input:\s+[\+]*([\-]*\d+\.\d)/) { + $temperature = $1; + last; + } +} +close(SENSORS); + +$temperature eq -9999 and die 'Cannot find temperature'; + +# Print short_text, full_text +print "$temperature°C\n" x2; + +# Print color, if needed +if ($temperature >= $t_crit) { + print "#FF0000\n"; + exit 33; +} elsif ($temperature >= $t_warn) { + print "#FFFC00\n"; +} + +exit 0; diff --git a/.config/i3blocks/temperature/temperature.png b/.config/i3blocks/temperature/temperature.png new file mode 100644 index 0000000..1f46fb3 Binary files /dev/null and b/.config/i3blocks/temperature/temperature.png differ diff --git a/.config/i3blocks/time/LICENSE b/.config/i3blocks/time/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/time/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/time/README.md b/.config/i3blocks/time/README.md new file mode 100644 index 0000000..88f6f5e --- /dev/null +++ b/.config/i3blocks/time/README.md @@ -0,0 +1,36 @@ +# time + +Shows the current time and changes displayed timezone on click. + +![](time.png) + +# Dependencies + +perl + +# Installation + +To use with i3blocks, copy the below configuration into your i3blocks configuration file + +```INI +[time] +command=$SCRIPT_DIR/time +interval=1 +#TZ_FILE=~/.tz +STRFTIME_FORMAT=%Y-%m-%d %H:%M +TZONES=$DEFAULT_TZ,Brazil/East,Australia/Brisbane,Asia/Calcutta +TZ_LABELS=,Brazil,AU,Hyderabad +``` + +See [strftime](https://linux.die.net/man/3/strftime) for allowed strftime formats. + +Here TZONES is a comma separated list of timeszones, see /usr/share/zoneinfo (Olson DB) +for allowed timezones. One exception is that the string $DEFAULT_TZ +is also allowed and represents whatever your current system timezone is. + +Also TZ_LABELS is a comma separated list of how to label each timezone in case you prefer +not to see the full timezone as part of the label. +E.g. you may want it to say "12:34 (US)" instead of "12:34 (America/Chicago)". +Labels are allowed to be empty, +in which case the script omits parentheses. +For example, in the config above, the label for the default timezone is omitted. diff --git a/.config/i3blocks/time/i3blocks.conf b/.config/i3blocks/time/i3blocks.conf new file mode 100644 index 0000000..8e93abb --- /dev/null +++ b/.config/i3blocks/time/i3blocks.conf @@ -0,0 +1,7 @@ +[time] +command=$SCRIPT_DIR/time +interval=1 +#TZ_FILE=~/.tz +STRFTIME_FORMAT=%Y-%m-%d %H:%M +TZONES=$DEFAULT_TZ,Brazil/East,Australia/Brisbane,Asia/Calcutta +TZ_LABELS=,Brazil,AU,Hyderabad diff --git a/.config/i3blocks/time/time b/.config/i3blocks/time/time new file mode 100755 index 0000000..725fc68 --- /dev/null +++ b/.config/i3blocks/time/time @@ -0,0 +1,100 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use POSIX qw/strftime/; + +my $click = $ENV{BLOCK_BUTTON} || 0; +my $format = $ENV{BLOCK_INSTANCE} || $ENV{STRFTIME_FORMAT} || "%H:%M"; +my $tz_file = shift || $ENV{TZ_FILE} || "$ENV{HOME}/.tz"; +$tz_file = glob($tz_file); +my $default_tz = get_default_tz(); + +my $tzones = $ENV{TZONES} || '$DEFAULT_TZ'; +$tzones =~ s/\$DEFAULT_TZ/$default_tz/g; +my @tz_list = split(/,/, $tzones); +my @tz_labels = split(/,/, $ENV{TZ_LABELS} || ""); +if (scalar(@tz_list) != scalar(@tz_labels)) { + @tz_labels = @tz_list; +} + +my $current_tz; +if ($click == 1) { + $current_tz = get_tz(); + + my %tzmap; + $tzmap{""} = $tz_list[0]; + my $prev = $tz_list[0]; + foreach my $tz (@tz_list) { + $tzmap{$prev} = $tz; + $prev = $tz; + } + $tzmap{$prev} = $tz_list[0]; + + if (exists $tzmap{$current_tz}) { + set_tz($tzmap{$current_tz}); + $current_tz = $tzmap{$current_tz}; + } +} + +# How each timezone will be displayed in the bar. +my %display_map; +for (my $i=0; $i < scalar(@tz_list); $i++) { + $display_map{$tz_list[$i]} = $tz_labels[$i]; +} + +if (!defined $current_tz) { + $current_tz = get_tz(); + set_tz($current_tz); +} +$ENV{TZ} = $current_tz; +my $tz_display = ""; +if (!exists $display_map{$ENV{TZ}}) { + $ENV{TZ} = $tz_list[0]; + set_tz($tz_list[0]); +} +$tz_display = $display_map{$ENV{TZ}}; + +my $time = strftime($format, localtime()); +if ($tz_display eq "") { + print "$time\n"; +} else { + print "$time ($tz_display)\n"; +} + +sub get_tz { + my $current_tz; + + if (-f $tz_file) { + open my $fh, '<', $tz_file || die "Couldn't open file: $tz_file"; + $current_tz = <$fh>; + chomp $current_tz; + close $fh; + } + + return $current_tz || get_default_tz(); +} + +sub set_tz { + my $tz = shift; + + open my $fh, '>', $tz_file || die "Couldn't open file: $tz_file"; + print $fh $tz; + close $fh; +} + +sub get_default_tz { + my $tz = "Europe/London"; + + if (-f "/etc/timezone") { + open my $fh, '<', "/etc/timezone" || die "Couldn't open file: /etc/timezone"; + $tz = <$fh>; + chomp $tz; + close $fh; + } elsif (-l "/etc/localtime") { + $tz = readlink "/etc/localtime"; + $tz = (split /zoneinfo\//, $tz)[-1]; + } + + return $tz; +} diff --git a/.config/i3blocks/time/time.png b/.config/i3blocks/time/time.png new file mode 100644 index 0000000..3658465 Binary files /dev/null and b/.config/i3blocks/time/time.png differ diff --git a/.config/i3blocks/usb/LICENSE b/.config/i3blocks/usb/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/usb/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/usb/README.md b/.config/i3blocks/usb/README.md new file mode 100644 index 0000000..f599cc1 --- /dev/null +++ b/.config/i3blocks/usb/README.md @@ -0,0 +1,85 @@ +# usb + +Output connected usb storage device info. +Supports usb mass storage devices, including those with multiple partitions, +including LUKS partitions. + +![](images/1.png) + +![](images/2.png) + +![](images/3.png) + +![](images/4.png) + + +# Requirements + +Dependencies: udev, python3, util-linux ( >= 2.23 ) + +Suggested: fonts-font-awesome + +# Installation +The recommended i3blocks config is + +```INI +[usb] +command=$SCRIPT_DIR/usb +markup=pango +signal=1 +interval=10 +#IGNORE_LIST=[] +#IGNORE_LIST=["sdd1", "mapper/sda1_crypt"] +#INFO_TEXT_COLOR=white +#MOUNTED_COLOR=green +#PLUGGED_COLOR=gray +#LOCKED_COLOR=gray +#UNLOCKED_NOT_MOUNTED_COLOR=yellow +#PARTITIONLESS_COLOR=red +#PARTITIONLESS_TEXT=no partitions +#SEPARATOR= | +#LOCKED_INDICATOR= +#UNLOCKED_INDICATOR= +#READONLY_INDICATOR=ro +#TRUNCATE_FS_LABELS=[not set by default, accepts +/- integers] +``` + +To update the blocklet on plug/unplug device events you can add + + SUBSYSTEMS=="usb", RUN+="/usr/bin/pkill -RTMIN+1 i3blocks" + +in `/etc/udev/rules.d/70-persistent-usb.rules`. +You may need to create the file. +Then call + +```ShellSession +sudo udevadm control --reload-rules +``` + +to activate the new rules. +If you do not care about updating the blocklet on plug/unplug, +the script works fine on just an interval and you can ignore the udev rule and +delete `signal=1` in the config. + +Now restart your i3 in place with + +```ShellSession +i3-msg restart +``` + +Try plugging in a usb device to make sure everything works. + +# Configuration + +The IGNORE_LIST variable, if set, must be a valid python representation of +a list of strings, e.g. `["sdd1", "mapper/sda1_crypt"]`. +Due to the way i3blocks parses config files, newlines are not allowed. +The strings are full device paths, with "/dev" optionally omitted. +For example, the previous "sdd1" is expanded to "/dev/sdd1" at runtime. +The list is safely parsed using ast.literal_eval, NOT eval. + +If you decide not to install FontAwesome, +then you will probably want to change the `LOCKED_INDICATOR` and +`UNLOCKED_INDICATOR` variables, as these use unicode symbols provided by +FontAwesome (and not many other fonts). +You do not need to restart i3 after making a change to the config. diff --git a/.config/i3blocks/usb/i3blocks.conf b/.config/i3blocks/usb/i3blocks.conf new file mode 100644 index 0000000..f2414bb --- /dev/null +++ b/.config/i3blocks/usb/i3blocks.conf @@ -0,0 +1,19 @@ +[usb] +command=$SCRIPT_DIR/usb +markup=pango +signal=1 +interval=10 +#IGNORE_LIST=[] +#IGNORE_LIST=["sdd1", "mapper/sda1_crypt"] +#INFO_TEXT_COLOR=white +#MOUNTED_COLOR=green +#PLUGGED_COLOR=gray +#LOCKED_COLOR=gray +#UNLOCKED_NOT_MOUNTED_COLOR=yellow +#PARTITIONLESS_COLOR=red +#PARTITIONLESS_TEXT=no partitions +#SEPARATOR= | +#LOCKED_INDICATOR= +#UNLOCKED_INDICATOR= +#READONLY_INDICATOR=ro +#TRUNCATE_FS_LABELS=[not set by default, accepts +/- integers] diff --git a/.config/i3blocks/usb/images/1.png b/.config/i3blocks/usb/images/1.png new file mode 100644 index 0000000..e1b70e5 Binary files /dev/null and b/.config/i3blocks/usb/images/1.png differ diff --git a/.config/i3blocks/usb/images/2.png b/.config/i3blocks/usb/images/2.png new file mode 100644 index 0000000..81ead8c Binary files /dev/null and b/.config/i3blocks/usb/images/2.png differ diff --git a/.config/i3blocks/usb/images/3.png b/.config/i3blocks/usb/images/3.png new file mode 100644 index 0000000..be93c6b Binary files /dev/null and b/.config/i3blocks/usb/images/3.png differ diff --git a/.config/i3blocks/usb/images/4.png b/.config/i3blocks/usb/images/4.png new file mode 100644 index 0000000..98f3523 Binary files /dev/null and b/.config/i3blocks/usb/images/4.png differ diff --git a/.config/i3blocks/usb/usb b/.config/i3blocks/usb/usb new file mode 100755 index 0000000..f74f0e4 --- /dev/null +++ b/.config/i3blocks/usb/usb @@ -0,0 +1,368 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2015 James Murphy +# Licensed under the terms of the GNU GPL v2 only. +# +# i3blocks blocklet script to output connected usb storage device info. + +import os + +def _default(name, default='', arg_type=str): + val = default + if name in os.environ: + val = os.environ[name] + return arg_type(val) + +############################################################################### +# BEGIN CONFIG +# Most of these can be specified as command line options, run with --help for +# more information. +# You may edit any of the following entries. DO NOT delete any of them, else +# the main script will have unpredictable behavior. +############################################################################### + +# Color options, can be a color name or #RRGGBB +INFO_TEXT_COLOR = _default("INFO_TEXT_COLOR", "white") +MOUNTED_COLOR = _default("MOUNTED_COLOR", "green") +PLUGGED_COLOR = _default("PLUGGED_COLOR", "gray") +LOCKED_COLOR = _default("LOCKED_COLOR", "gray") +UNLOCKED_NOT_MOUNTED_COLOR = _default("UNLOCKED_NOT_MOUNTED_COLOR", "yellow") +PARTITIONLESS_COLOR = _default("PARTITIONLESS_COLOR", "red") + +# Default texts +PARTITIONLESS_TEXT = _default("PARTITIONLESS_TEXT", "no partitions") +SEPARATOR = _default("SEPARATOR", " | ") + +# Indicate whether an encrypted partition is locked/unlocked, "" is allowed. +LOCKED_INDICATOR = _default("LOCKED_INDICATOR", "\uf023 ") +UNLOCKED_INDICATOR = _default("UNLOCKED_INDICATOR", "\uf09c ") + +# Shows instead of space available when a partition is mounted readonly +READONLY_INDICATOR = _default("READONLY_INDICATOR", "ro") + +# Maximum length of a filesystem label to display. Use None to disable +# truncation, a positive integer to right truncate to that many characters, or +# a negative integer to left truncate to that many characters. Setting this +# option to 0 will disable the displaying of filesystem labels. +TRUNCATE_FS_LABELS = _default("TRUNCASE_FS_LABELS", None) + +# List of devices to ignore. Must be a valid python3 representation of a list +# of strings +IGNORE_LIST = _default("IGNORE_LIST", "[]") +if IGNORE_LIST: + import ast + IGNORE_LIST = list(map(lambda p: + p if p.startswith("/") + else "/dev/{}".format(p), + ast.literal_eval(IGNORE_LIST) + )) + + +# Edit this function to ignore certain devices (e.g. those that are always +# plugged in). +# The dictionary udev_attributes_dict contains all the attributes given by +# udevadm info --query=propery --name=$path +def ignore(path, udev_attributes_dict): + # E.g. how to ignore devices whose device name begins with /dev/sda + #if udev_attributes_dict["DEVNAME"].startswith("/dev/sda"): + # return True + return False + +# Edit this function to ignore devices before the udev attributes are +# computed in order to save time and memory. +def fastIgnore(path): + if path in IGNORE_LIST: + return True + + # E.g. how to to ignore devices whose path begins with /dev/sda + #if path.startswith("/dev/sda"): + # return True + + # E.g. how to ignore a fixed set of paths + #if path in [ "/dev/path1", "/dev/path2", "/dev/path3" ]: + # return True + return False + +############################################################################### +# END CONFIG +# DO NOT EDIT ANYTHING AFTER THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING +############################################################################### + +from subprocess import check_output +import argparse + +def pangoEscape(text): + return text.replace("&", "&").replace("<", "<").replace(">", ">") + +def getLeafDevicePaths(): + lines = check_output(['lsblk', '-spndo', 'NAME'], universal_newlines=True) + lines = lines.split("\n") + lines = filter(None, lines) + return lines + +def getKernelName(path): + return check_output(['lsblk', '-ndso', 'KNAME', path], + universal_newlines=True).rstrip("\n") + +def getDeviceType(path): + return check_output(['lsblk', '-no', 'TYPE', path], + universal_newlines=True).strip() + +def getFSType(path): + global attributeMaps + return attributeMaps[path].get("ID_FS_TYPE") + +def isLUKSPartition(path): + return getFSType(path) == "crypto_LUKS" + +def isSwapPartition(path): + return getFSType(path) == "swap" + +def getFSLabel(path): + global attributeMaps + label = attributeMaps[path].get("ID_FS_LABEL_ENC", "") + if label: + label = label.encode().decode("unicode-escape") + if type(TRUNCATE_FS_LABELS) == int: + if TRUNCATE_FS_LABELS >= 0: + label = label[:TRUNCATE_FS_LABELS] + elif TRUNCATE_FS_LABELS < 0: + label = label[TRUNCATE_FS_LABELS:] + return label + +def getFSOptions(path): + lines = check_output(['findmnt', '-no', 'FS-OPTIONS', path], + universal_newlines=True).strip() + lines = lines.split(",") + return lines + +def isReadOnly(path): + return "ro" in getFSOptions(path) + +def isExtendedPartitionMarker(path): + global attributeMaps + MARKERS = ["0xf", "0x5"] + return attributeMaps[path].get("ID_PART_ENTRY_TYPE") in MARKERS + +def getMountPoint(path): + return check_output(['lsblk', '-ndo', 'MOUNTPOINT', path], + universal_newlines=True).rstrip("\n") + +def getSpaceAvailable(path): + lines = check_output(['df', '-h', '--output=avail', path], + universal_newlines=True) + lines = lines.split("\n") + if len(lines) != 3: + return "" + else: + return lines[1].strip() + +def getLockedCryptOutput(path): + form = "[{}{}]" + kname = pangoEscape(getKernelName(path)) + output = form.format(LOCKED_COLOR, LOCKED_INDICATOR, kname) + return output + +def getParentKernelName(path): + lines = check_output(['lsblk', '-nso', 'KNAME', path], + universal_newlines=True) + lines = lines.split("\n") + if len(lines) > 2: + return lines[1].rstrip("\n") + else: + return "" + +def getUnlockedCryptOutput(path): + mountPoint = getMountPoint(path) + if mountPoint: + color = MOUNTED_COLOR + if isReadOnly(path): + spaceAvail = READONLY_INDICATOR + else: + spaceAvail = pangoEscape(getSpaceAvailable(path)) + mountPoint = "{}:".format(pangoEscape(mountPoint)) + else: + color = UNLOCKED_NOT_MOUNTED_COLOR + spaceAvail = "" + kernelName = pangoEscape(getKernelName(path)) + parentKernelName = pangoEscape(getParentKernelName(path)) + + block = "[{}{}:{}]" + block = block.format(color, UNLOCKED_INDICATOR, parentKernelName, kernelName) + + label = pangoEscape(getFSLabel(path)) + if label: + label = '"{}"'.format(label) + + items = [block, label, mountPoint, spaceAvail] + return " ".join(filter(None, items)) + +def getSwapOutput(path): + return "" + +def getUnencryptedPartitionOutput(path): + mountPoint = getMountPoint(path) + if mountPoint: + color = MOUNTED_COLOR + if isReadOnly(path): + spaceAvail = READONLY_INDICATOR + else: + spaceAvail = pangoEscape(getSpaceAvailable(path)) + mountPoint = "{}:".format(pangoEscape(mountPoint)) + else: + color = PLUGGED_COLOR + spaceAvail = "" + kernelName = pangoEscape(getKernelName(path)) + + block = "[{}]" + block = block.format(color, kernelName) + + label = pangoEscape(getFSLabel(path)) + if label: + label = '"{}"'.format(label) + + items = [block, label, mountPoint, spaceAvail] + return " ".join(filter(None, items)) + +def getDiskWithNoPartitionsOutput(path): + form = "[{}] {}" + kernelName = pangoEscape(getKernelName(path)) + return form.format(PARTITIONLESS_COLOR, kernelName, PARTITIONLESS_TEXT) + +def getOutput(path): + if isSwapPartition(path): + return getSwapOutput(path) + t = getDeviceType(path) + if t == "part": + if isExtendedPartitionMarker(path): + return "" + elif isLUKSPartition(path): + return getLockedCryptOutput(path) + else: + return getUnencryptedPartitionOutput(path) + elif t == "disk": + return getDiskWithNoPartitionsOutput(path) + elif t == "crypt": + return getUnlockedCryptOutput(path) + elif t == "rom" : + return "" + +def makeAttributeMap(path): + attributeMap = {} + lines = check_output( + ['udevadm','info','--query=property','--name={}'.format(path)], + universal_newlines=True) + lines = lines.split("\n") + for line in lines: + if line: + key, val = line.split("=", maxsplit=1) + attributeMap[key] = val + return attributeMap + +def getAttributeMaps(paths): + return {path : makeAttributeMap(path) for path in paths} + +def parseArguments(): + parser = argparse.ArgumentParser(prog="usb.py", + description="i3blocks blocklet script to output connected" + " usb storage device info") + parser.add_argument("--info-text-color", nargs=1, + help="Set the info text color. " + "Default: {}".format(INFO_TEXT_COLOR)) + parser.add_argument("--mounted-color", nargs=1, + help="Set the color of mounted devices. " + "Default: {}".format(MOUNTED_COLOR)) + parser.add_argument("--plugged-color", nargs=1, + help="Set the color of plugged devices. " + "Default: {}".format(PLUGGED_COLOR)) + parser.add_argument("--locked-color", nargs=1, + help="Set the color of locked crypt devices. " + "Default: {}".format(LOCKED_COLOR)) + parser.add_argument("--unlocked-not-mounted-color", nargs=1, + help="Set the color of unlocked not mounted crypt devices. " + "Default: {}".format(UNLOCKED_NOT_MOUNTED_COLOR)) + parser.add_argument("--partitionless-color", nargs=1, + help="Set the color of devicees with no partitions. " + "Defaut: {}".format(PARTITIONLESS_COLOR)) + parser.add_argument("--partitionless-text", nargs=1, + help="Set the text to display for a device with no partitions. " + "Default: {}".format(PARTITIONLESS_TEXT)) + parser.add_argument("--separator", nargs=1, + help="Set the separator between devices. " + "Default: {}".format(SEPARATOR)) + parser.add_argument("--locked-indicator", nargs=1, + help="Set the indicator to use for a locked crypt device. " + "Default: {}".format(LOCKED_INDICATOR)) + parser.add_argument("--unlocked-indicator", nargs=1, + help="Set the indicator to use for an unlocked crypt device. " + "Default: {}".format(UNLOCKED_INDICATOR)) + parser.add_argument("--readonly-indicator", nargs=1, + help="Set the indicator to use for a readonly device. " + "Default: {}".format(READONLY_INDICATOR)) + parser.add_argument("--truncate-fs-labels", type=int, nargs=1, + help="Trucate device labels to a certain number of characters, must be" + "an integer." + "Default: {}".format(TRUNCATE_FS_LABELS)) + parser.add_argument("-i", "--ignore", action="append", + help="Ignore a device by path. " + "If path doesn't begin with / then it is assumed to be in /dev/") + args = parser.parse_args() + setParsedArgs(args) + +def setParsedArgs(args): + if args.info_text_color != None: + global INFO_TEXT_COLOR + INFO_TEXT_COLOR = args.info_text_color[0] + if args.mounted_color != None: + global MOUNTED_COLOR + MOUNTED_COLOR = args.mounted_color[0] + if args.plugged_color != None: + global PLUGGED_COLOR + PLUGGED_COLOR = args.plugged_color[0] + if args.locked_color != None: + global LOCKED_COLOR + LOCKED_COLOR = args.locked_color[0] + if args.unlocked_not_mounted_color != None: + global UNLOCKED_NOT_MOUNTED_COLOR + UNLOCKED_NOT_MOUNTED_COLOR = args.unlocked_not_mounted_color[0] + if args.partitionless_color != None: + global PARTITIONLESS_COLOR + PARTITIONLESS_COLOR = args.partitionless_color[0] + if args.partitionless_text != None: + global PARTITIONLESS_TEXT + PARTITIONLESS_TEXT = args.partitionless_text[0] + if args.separator != None: + global SEPARATOR + SEPARATOR = args.separator[0] + if args.locked_indicator != None: + global LOCKED_INDICATOR + LOCKED_INDICATOR = args.locked_indicator[0] + if args.unlocked_indicator != None: + global UNLOCKED_INDICATOR + UNLOCKED_INDICATOR = args.unlocked_indicator[0] + if args.readonly_indicator != None: + global READONLY_INDICATOR + READONLY_INDICATOR = args.readonly_indicator[0] + if args.truncate_fs_labels != None: + global TRUNCATE_FS_LABELS + TRUNCATE_FS_LABELS = args.truncate_fs_labels[0] + if args.ignore != None: + args.ignore = list(map(lambda p: + p if p.startswith("/") else "/dev/{}".format(p), args.ignore)) + global fastIgnore + oldFastIgnore = fastIgnore + def newFastIgnore(path): + return oldFastIgnore(path) or path in args.ignore + fastIgnore = newFastIgnore + +parseArguments() +leaves = getLeafDevicePaths() +leaves = [path for path in leaves if not fastIgnore(path)] +attributeMaps = getAttributeMaps(leaves) +leaves = (path for path in leaves if not ignore(path, attributeMaps[path])) +outputs = filter(None, map(getOutput, leaves)) +output = SEPARATOR.join(outputs) +if output: + output = "{}".format(INFO_TEXT_COLOR, output) +print(output) +print(output) diff --git a/.config/i3blocks/volume-pulseaudio/LICENSE b/.config/i3blocks/volume-pulseaudio/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/volume-pulseaudio/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/volume-pulseaudio/README.md b/.config/i3blocks/volume-pulseaudio/README.md new file mode 100644 index 0000000..75bffde --- /dev/null +++ b/.config/i3blocks/volume-pulseaudio/README.md @@ -0,0 +1,63 @@ +# volume-pulseaudio + +Display the system volume and +optionally the default playback device and indeax. +Offers controls for these via clicks/scrolling. +Supports changing audiostreams that are already playing. + +![](volume-pulseaudio-high.png) +![](volume-pulseaudio-med.png) +![](volume-pulseaudio-low.png) +![](volume-pulseaudio-mute.png) + +# Dependencies + +pulseaudio, alsa (alsa-utils package), fontawesome (fonts-font-awesome package) for the speaker symbols + +# Usage + +Left/right clicks change default playback device, middle click mutes, scrolling +adjusts volume. If your keyboard has audio buttons, it is suggested to add the +the following to your i3 config + +``` +# change volume or toggle mute +bindsym XF86AudioRaiseVolume exec amixer -q -D pulse sset Master 5%+ && pkill -RTMIN+1 i3blocks +bindsym XF86AudioLowerVolume exec amixer -q -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks +bindsym XF86AudioMute exec amixer -q -D pulse sset Master toggle && pkill -RTMIN+1 i3blocks +``` + +where the number `1` in `-RTMIN+1` can be replaced to another signal number, +as long as it agrees what you put for `signal=` in your i3blocks config. +The previous lines also assume your mixer is "pulse" and your scontrol is "Master". +If yours are different, change them appropriately. + +Alternatively to using signals, you may use the `SUBSCRIBE=1` option in your config in order to have the block +automatically respond to audio change events. This option requires `interval=persist` +and always uses the `LONG_FORMAT`. + +# Config + +```INI +[volume-pulseaudio] +command=$SCRIPT_DIR/volume-pulseaudio +interval=once +signal=1 +#MIXER=[determined automatically] +#SCONTROL=[determined automatically] +##exposed format variables: ${SYMB}, ${VOL}, ${INDEX}, ${NAME} +#LONG_FORMAT="${SYMB} ${VOL}% [${INDEX}:${NAME}]" +#SHORT_FORMAT="${SYMB} ${VOL}% [${INDEX}]" +#AUDIO_HIGH_SYMBOL=' ' +#AUDIO_MED_THRESH=50 +#AUDIO_MED_SYMBOL=' ' +#AUDIO_LOW_THRESH=0 +#AUDIO_LOW_SYMBOL=' ' +#AUDIO_DELTA=5 +#DEFAULT_COLOR="#ffffff" +#MUTED_COLOR="#a0a0a0" +#USE_ALSA_NAME=0 +#USE_DESCRIPTION=0 +## SUBSCRIBE=1 requires interval=persist and always uses LONG_FORMAT +#SUBSCRIBE=0 +``` diff --git a/.config/i3blocks/volume-pulseaudio/i3blocks.conf b/.config/i3blocks/volume-pulseaudio/i3blocks.conf new file mode 100644 index 0000000..247246b --- /dev/null +++ b/.config/i3blocks/volume-pulseaudio/i3blocks.conf @@ -0,0 +1,14 @@ +#if you prefer automatic updating +[volume-pulseaudio] +command=$SCRIPT_DIR/volume-pulseaudio +interval=persist +SUBSCRIBE=1 +USE_ALSA_NAME=1 + + +#if you prefer updating only when signaled +[volume-pulseaudio] +command=$SCRIPT_DIR/volume-pulseaudio +interval=once +signal=1 +USE_ALSA_NAME=1 diff --git a/.config/i3blocks/volume-pulseaudio/volume-pulseaudio b/.config/i3blocks/volume-pulseaudio/volume-pulseaudio new file mode 100755 index 0000000..ad1b2d1 --- /dev/null +++ b/.config/i3blocks/volume-pulseaudio/volume-pulseaudio @@ -0,0 +1,175 @@ +#!/bin/bash +# Displays the default device, volume, and mute status for i3blocks + +set -a + +AUDIO_HIGH_SYMBOL=${AUDIO_HIGH_SYMBOL:-' '} + +AUDIO_MED_THRESH=${AUDIO_MED_THRESH:-50} +AUDIO_MED_SYMBOL=${AUDIO_MED_SYMBOL:-' '} + +AUDIO_LOW_THRESH=${AUDIO_LOW_THRESH:-0} +AUDIO_LOW_SYMBOL=${AUDIO_LOW_SYMBOL:-' '} + +AUDIO_MUTED_SYMBOL=${AUDIO_MUTED_SYMBOL:-' '} + +AUDIO_DELTA=${AUDIO_DELTA:-5} + +DEFAULT_COLOR=${DEFAULT_COLOR:-"#ffffff"} +MUTED_COLOR=${MUTED_COLOR:-"#a0a0a0"} + +LONG_FORMAT=${LONG_FORMAT:-'${SYMB} ${VOL}% [${INDEX}:${NAME}]'} +SHORT_FORMAT=${SHORT_FORMAT:-'${SYMB} ${VOL}% [${INDEX}]'} +USE_ALSA_NAME=${USE_ALSA_NAME:-0} +USE_DESCRIPTION=${USE_DESCRIPTION:-0} + +SUBSCRIBE=${SUBSCRIBE:-0} + +MIXER=${MIXER:-""} +SCONTROL=${SCONTROL:-""} + +while getopts F:Sf:adH:M:L:X:T:t:C:c:i:m:s:h opt; do + case "$opt" in + S) SUBSCRIBE=1 ;; + F) LONG_FORMAT="$OPTARG" ;; + f) SHORT_FORMAT="$OPTARG" ;; + a) USE_ALSA_NAME=1 ;; + d) USE_DESCRIPTION=1 ;; + H) AUDIO_HIGH_SYMBOL="$OPTARG" ;; + M) AUDIO_MED_SYMBOL="$OPTARG" ;; + L) AUDIO_LOW_SYMBOL="$OPTARG" ;; + X) AUDIO_MUTED_SYMBOL="$OPTARG" ;; + T) AUDIO_MED_THRESH="$OPTARG" ;; + t) AUDIO_LOW_THRESH="$OPTARG" ;; + C) DEFAULT_COLOR="$OPTARG" ;; + c) MUTED_COLOR="$OPTARG" ;; + i) AUDIO_INTERVAL="$OPTARG" ;; + m) MIXER="$OPTARG" ;; + s) SCONTROL="$OPTARG" ;; + h) printf \ +"Usage: volume-pulseaudio [-S] [-F format] [-f format] [-p] [-a|-d] [-H symb] [-M symb] + [-L symb] [-X symb] [-T thresh] [-t thresh] [-C color] [-c color] [-i inter] + [-m mixer] [-s scontrol] [-h] +Options: +-F, -f\tOutput format (-F long format, -f short format) to use, with exposed variables: +\${SYMB}, \${VOL}, \${INDEX}, \${NAME} +-S\tSubscribe to volume events (requires persistent block, always uses long format) +-a\tUse ALSA name if possible +-d\tUse device description instead of name if possible +-H\tSymbol to use when audio level is high. Default: '$AUDIO_HIGH_SYMBOL' +-M\tSymbol to use when audio level is medium. Default: '$AUDIO_MED_SYMBOL' +-L\tSymbol to use when audio level is low. Default: '$AUDIO_LOW_SYMBOL' +-X\tSymbol to use when audio is muted. Default: '$AUDIO_MUTED_SYMBOL' +-T\tThreshold for medium audio level. Default: $AUDIO_MED_THRESH +-t\tThreshold for low audio level. Default: $AUDIO_LOW_THRESH +-C\tColor for non-muted audio. Default: $DEFAULT_COLOR +-c\tColor for muted audio. Default: $MUTED_COLOR +-i\tInterval size of volume increase/decrease. Default: $AUDIO_DELTA +-m\tUse the given mixer. +-s\tUse the given scontrol. +-h\tShow this help text +" && exit 0;; + esac +done + +if [[ -z "$MIXER" ]] ; then + MIXER="default" + if amixer -D pulse info >/dev/null 2>&1 ; then + MIXER="pulse" + fi +fi + +if [[ -z "$SCONTROL" ]] ; then + SCONTROL=$(amixer -D "$MIXER" scontrols | sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | head -n1) +fi + +CAPABILITY=$(amixer -D $MIXER get $SCONTROL | sed -n "s/ Capabilities:.*cvolume.*/Capture/p") + + +function move_sinks_to_new_default { + DEFAULT_SINK=$1 + pacmd list-sink-inputs | grep index: | grep -o '[0-9]\+' | while read SINK + do + pacmd move-sink-input $SINK $DEFAULT_SINK + done +} + +function set_default_playback_device_next { + inc=${1:-1} + num_devices=$(pacmd list-sinks | grep -c index:) + sink_arr=($(pacmd list-sinks | grep index: | grep -o '[0-9]\+')) + default_sink_index=$(( $(pacmd list-sinks | grep index: | grep -no '*' | grep -o '^[0-9]\+') - 1 )) + default_sink_index=$(( ($default_sink_index + $num_devices + $inc) % $num_devices )) + default_sink=${sink_arr[$default_sink_index]} + pacmd set-default-sink $default_sink + move_sinks_to_new_default $default_sink +} + +case "$BLOCK_BUTTON" in + 1) set_default_playback_device_next ;; + 2) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY toggle ;; + 3) set_default_playback_device_next -1 ;; + 4) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%+ ;; + 5) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%- ;; +esac + +function print_format { + echo "$1" | envsubst '${SYMB}${VOL}${INDEX}${NAME}' +} + +function print_block { + ACTIVE=$(pacmd list-sinks | grep "state\: RUNNING" -B4 -A7 | grep "index:\|name:\|volume: front\|muted:") + [ -z "$ACTIVE" ] && ACTIVE=$(pacmd list-sinks | grep "index:\|name:\|volume: front\|muted:" | grep -A3 '*') + for name in INDEX NAME VOL MUTED; do + read $name + done < <(echo "$ACTIVE") + INDEX=$(echo "$INDEX" | grep -o '[0-9]\+') + VOL=$(echo "$VOL" | grep -o "[0-9]*%" | head -1 ) + VOL="${VOL%?}" + + NAME=$(echo "$NAME" | sed \ +'s/.*<.*\.\(.*\)>.*/\1/; t;'\ +'s/.*<\(.*\)>.*/\1/; t;'\ +'s/.*/unknown/') + + if [[ $USE_ALSA_NAME == 1 ]] ; then + ALSA_NAME=$(pacmd list-sinks |\ +awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\ +grep "alsa.name\|alsa.mixer_name" |\ +head -n1 |\ +sed 's/.*= "\(.*\)".*/\1/') + NAME=${ALSA_NAME:-$NAME} + elif [[ $USE_DESCRIPTION == 1 ]] ; then + DESCRIPTION=$(pacmd list-sinks |\ +awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\ +grep "device.description" |\ +head -n1 |\ +sed 's/.*= "\(.*\)".*/\1/') + NAME=${DESCRIPTION:-$NAME} + fi + + if [[ $MUTED =~ "no" ]] ; then + SYMB=$AUDIO_HIGH_SYMBOL + [[ $VOL -le $AUDIO_MED_THRESH ]] && SYMB=$AUDIO_MED_SYMBOL + [[ $VOL -le $AUDIO_LOW_THRESH ]] && SYMB=$AUDIO_LOW_SYMBOL + COLOR=$DEFAULT_COLOR + else + SYMB=$AUDIO_MUTED_SYMBOL + COLOR=$MUTED_COLOR + fi + + if [[ $SUBSCRIBE == 1 ]] ; then + print_format "$LONG_FORMAT" + else + print_format "$LONG_FORMAT" + print_format "$SHORT_FORMAT" + echo "$COLOR" + fi +} + +print_block +if [[ $SUBSCRIBE == 1 ]] ; then + while read -r EVENT; do + print_block + done < <(pactl subscribe | stdbuf -oL grep change) +fi diff --git a/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-high.png b/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-high.png new file mode 100644 index 0000000..fe2ad82 Binary files /dev/null and b/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-high.png differ diff --git a/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-low.png b/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-low.png new file mode 100644 index 0000000..44989c3 Binary files /dev/null and b/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-low.png differ diff --git a/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-med.png b/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-med.png new file mode 100644 index 0000000..71ec846 Binary files /dev/null and b/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-med.png differ diff --git a/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-mute.png b/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-mute.png new file mode 100644 index 0000000..060009a Binary files /dev/null and b/.config/i3blocks/volume-pulseaudio/volume-pulseaudio-mute.png differ diff --git a/.config/i3blocks/volume/README.md b/.config/i3blocks/volume/README.md new file mode 100644 index 0000000..66e15a4 --- /dev/null +++ b/.config/i3blocks/volume/README.md @@ -0,0 +1,45 @@ +# volume + +Shows the current system volume. The first parameter sets the step (and units +to display). The second parameter overrides the mixer selection. +See the script for details. + +Scrolling on the block changes the volume. Right clicking toggles mute. + +![](volume.png) + +# Usage + +This block can be run on an interval or by signal. To run the block using a +signal, it is recommended to add the following to your i3 config. + +``` +# change volume or toggle mute +bindsym XF86AudioRaiseVolume exec amixer -q -D pulse sset Master 5%+ && pkill -RTMIN+10 i3blocks +bindsym XF86AudioLowerVolume exec amixer -q -D pulse sset Master 5%- && pkill -RTMIN+10 i3blocks +bindsym XF86AudioMute exec amixer -q -D pulse sset Master toggle && pkill -RTMIN+10 i3blocks +``` + +where the number `10` in `-RTMIN+10` can be replaced to another signal number, +as long as it agrees what you put for `signal=` in your i3blocks config. + + +# Config + +``` +[volume] +command=$SCRIPT_DIR/volume +#LABEL=♪ +LABEL=VOL +interval=once +signal=10 +#STEP=5% +#MIXER=[determined automatically] +#SCONTROL=[determined automatically] +``` +For PulseAudio users, MIXER is usually "pulse" or "default". +For Jack/Jack2 users, MIXER is usually "jackplug". +For ALSA users, use "default" for your primary card, or "hw:#" +where # is the number of the card desired. + +For a list of available SCONTROL options, use `amixer -D $MIXER scontrols`. diff --git a/.config/i3blocks/volume/i3blocks.conf b/.config/i3blocks/volume/i3blocks.conf new file mode 100644 index 0000000..1e257e2 --- /dev/null +++ b/.config/i3blocks/volume/i3blocks.conf @@ -0,0 +1,9 @@ +[volume] +command=$SCRIPT_DIR/volume +#LABEL=♪ +LABEL=VOL +interval=once +signal=10 +#STEP=5% +#MIXER=[determined automatically] +#SCONTROL=[determined automatically] diff --git a/.config/i3blocks/volume/volume b/.config/i3blocks/volume/volume new file mode 100755 index 0000000..86e021f --- /dev/null +++ b/.config/i3blocks/volume/volume @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# Copyright (C) 2014 Julien Bonjean +# Copyright (C) 2014 Alexander Keller + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +#------------------------------------------------------------------------ + +# The second parameter overrides the mixer selection +# For PulseAudio users, eventually use "pulse" +# For Jack/Jack2 users, use "jackplug" +# For ALSA users, you may use "default" for your primary card +# or you may use hw:# where # is the number of the card desired +if [[ -z "$MIXER" ]] ; then + MIXER="default" + if command -v pulseaudio >/dev/null 2>&1 && pulseaudio --check ; then + # pulseaudio is running, but not all installations use "pulse" + if amixer -D pulse info >/dev/null 2>&1 ; then + MIXER="pulse" + fi + fi + [ -n "$(lsmod | grep jack)" ] && MIXER="jackplug" + MIXER="${2:-$MIXER}" +fi + +# The instance option sets the control to report and configure +# This defaults to the first control of your selected mixer +# For a list of the available, use `amixer -D $Your_Mixer scontrols` +if [[ -z "$SCONTROL" ]] ; then + SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols | + sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | + head -n1 + )}" +fi + +# The first parameter sets the step to change the volume by (and units to display) +# This may be in in % or dB (eg. 5% or 3dB) +if [[ -z "$STEP" ]] ; then + STEP="${1:-5%}" +fi + +#------------------------------------------------------------------------ + +capability() { # Return "Capture" if the device is a capture device + amixer -D $MIXER get $SCONTROL | + sed -n "s/ Capabilities:.*cvolume.*/Capture/p" +} + +volume() { + amixer -D $MIXER get $SCONTROL $(capability) +} + +format() { + + perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)' + perl_filter+='{CORE::say $4 eq "off" ? "mute" : "' + # If dB was selected, print that instead + perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1') + perl_filter+='"; exit}' + output=$(perl -ne "$perl_filter") + echo "$LABEL$output" +} + +#------------------------------------------------------------------------ + +case $BLOCK_BUTTON in + 3) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute + 4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase + 5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease +esac + +volume | format diff --git a/.config/i3blocks/volume/volume.png b/.config/i3blocks/volume/volume.png new file mode 100644 index 0000000..2eba45e Binary files /dev/null and b/.config/i3blocks/volume/volume.png differ diff --git a/.config/i3blocks/wifi/README.md b/.config/i3blocks/wifi/README.md new file mode 100644 index 0000000..f6c1052 --- /dev/null +++ b/.config/i3blocks/wifi/README.md @@ -0,0 +1,16 @@ +# wifi + +Show the strength of your wifi connection. +If no instance is specified, wlan0 is used. + +![](wifi.png) + +# Config + +``` +[wifi] +command=$SCRIPT_DIR/wifi +label=wifi: +#INTERFACE=wlan0 +interval=60 +``` diff --git a/.config/i3blocks/wifi/i3blocks.conf b/.config/i3blocks/wifi/i3blocks.conf new file mode 100644 index 0000000..e207173 --- /dev/null +++ b/.config/i3blocks/wifi/i3blocks.conf @@ -0,0 +1,5 @@ +[wifi] +command=$SCRIPT_DIR/wifi +label=wifi: +#INTERFACE=wlan0 +interval=60 diff --git a/.config/i3blocks/wifi/wifi b/.config/i3blocks/wifi/wifi new file mode 100755 index 0000000..34b6348 --- /dev/null +++ b/.config/i3blocks/wifi/wifi @@ -0,0 +1,53 @@ +#!/bin/bash +# Copyright (C) 2014 Alexander Keller + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +#------------------------------------------------------------------------ +if [[ -z "$INTERFACE" ]] ; then + INTERFACE="${BLOCK_INSTANCE:-wlan0}" +fi +#------------------------------------------------------------------------ + +# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless +# connection (think desktop), the corresponding block should not be displayed. +[[ ! -d /sys/class/net/${INTERFACE}/wireless ]] && exit + +# If the wifi interface exists but no connection is active, "down" shall be displayed. +if [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]]; then + echo "down" + echo "down" + echo "#FF0000" + exit +fi + +#------------------------------------------------------------------------ + +QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') + +#------------------------------------------------------------------------ + +echo $QUALITY% # full text +echo $QUALITY% # short text + +# color +if [[ $QUALITY -ge 80 ]]; then + echo "#00FF00" +elif [[ $QUALITY -ge 60 ]]; then + echo "#FFF600" +elif [[ $QUALITY -ge 40 ]]; then + echo "#FFAE00" +else + echo "#FF0000" +fi diff --git a/.config/i3blocks/wifi/wifi.png b/.config/i3blocks/wifi/wifi.png new file mode 100644 index 0000000..5549de6 Binary files /dev/null and b/.config/i3blocks/wifi/wifi.png differ diff --git a/.config/i3blocks/wlan-dbm/README.md b/.config/i3blocks/wlan-dbm/README.md new file mode 100644 index 0000000..f7c6147 --- /dev/null +++ b/.config/i3blocks/wlan-dbm/README.md @@ -0,0 +1,24 @@ +# wlan-dbm + +Show wifi interface link quality in dBm or percent. + +![](wlan-dbm.png) + +# Usage + +The block uses dBm by default, set USE_PERCENT=1 to use percent. +Note, however, that percent is just an estimate that may not accurately predict +whether you have a good signal. + +# Dependencies + +* `iw` + +# Config + +```INI +[wlan-dbm] +command=$SCRIPT_DIR/wlan-dbm +#IFACE=wlan0 +#USE_PERCENT=0 +``` diff --git a/.config/i3blocks/wlan-dbm/wlan-dbm b/.config/i3blocks/wlan-dbm/wlan-dbm new file mode 100755 index 0000000..7a121d4 --- /dev/null +++ b/.config/i3blocks/wlan-dbm/wlan-dbm @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# +# i3blocks blocklet script to display wifi signal in dBm + +if [[ -z "$IFACE" ]] ; then + IFACE="${BLOCK_INSTANCE:-wlan0}" +fi + +USE_PERCENT=${USE_PERCENT:-0} + +IW=$(which iw || echo "/sbin/iw") + +if [[ ! -x $IW ]]; then + echo "No iw binary was found on the system." 1>2 + exit 1 +fi + +while getopts p opt; do + case "$opt" in + p) USE_PERCENT=1 ;; + esac +done + +dbm=$($IW dev "$IFACE" link | grep 'dBm$' | grep -Eoe '-[0-9]{2}') + +[[ -n "$dbm" ]] || exit 1 + +if [[ $USE_PERCENT -eq 0 ]]; then + echo "$dbm" dBm + echo "$dbm" +else + if [[ "$dbm" -le -100 ]]; then + quality=0 + elif [[ $dbm -ge -50 ]]; then + quality=100 + else + quality=$((2 * (dbm + 100))) + fi + echo "$quality%" + echo "$quality%" +fi + +if [[ $dbm -ge -55 ]]; then + echo "#00FF00" +elif [[ $dbm -ge -60 ]]; then + echo "#CCFF00" +elif [[ $dbm -ge -70 ]]; then + echo "#FFFF00" +elif [[ $dbm -ge -80 ]]; then + echo "#FFAA00" +else + echo "#FF0000" +fi diff --git a/.config/i3blocks/wlan-dbm/wlan-dbm.png b/.config/i3blocks/wlan-dbm/wlan-dbm.png new file mode 100644 index 0000000..df10fb8 Binary files /dev/null and b/.config/i3blocks/wlan-dbm/wlan-dbm.png differ diff --git a/.config/i3blocks/ytdl-mpv/LICENSE b/.config/i3blocks/ytdl-mpv/LICENSE new file mode 100644 index 0000000..8cdb845 --- /dev/null +++ b/.config/i3blocks/ytdl-mpv/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/.config/i3blocks/ytdl-mpv/README.md b/.config/i3blocks/ytdl-mpv/README.md new file mode 100644 index 0000000..78c11ef --- /dev/null +++ b/.config/i3blocks/ytdl-mpv/README.md @@ -0,0 +1,28 @@ +# ytdl-mpv + +Play youtube videos (any video compatible with youtube-dl) from your clipboard. +Left click for video, middle click for audio, right click to kill all instances of mpv. + +![](ytdl-mpv.png) + +# Requirements + +Dependencies: fonts-font-awesome, mpv, xclip, youtube-dl, perl, Data::Validate::URI perl module +(libdata-validate-uri-perl package) + +# Installation + +The recommended i3blocks config is + +```INI +[ytdl-mpv] +command=$SCRIPT_DIR/ytdl-mpv +markup=pango +interval=once +signal=4 +#CACHE_DEFAULT=1048576 +#PLAYING_COLOR=red +#NOT_PLAYING_COLOR=white +``` + +Copy a youtube URL into your clipboard and then click on the blocklet to make sure everything works. diff --git a/.config/i3blocks/ytdl-mpv/i3blocks.conf b/.config/i3blocks/ytdl-mpv/i3blocks.conf new file mode 100644 index 0000000..cfff838 --- /dev/null +++ b/.config/i3blocks/ytdl-mpv/i3blocks.conf @@ -0,0 +1,5 @@ +[ytdl-mpv] +command=$SCRIPT_DIR/ytdl-mpv +markup=pango +interval=once +signal=4 diff --git a/.config/i3blocks/ytdl-mpv/ytdl-mpv b/.config/i3blocks/ytdl-mpv/ytdl-mpv new file mode 100755 index 0000000..a769fa9 --- /dev/null +++ b/.config/i3blocks/ytdl-mpv/ytdl-mpv @@ -0,0 +1,50 @@ +#!/usr/bin/env perl +# +# Copyright (C) 2018 James Murphy +# Licensed under the terms of the GNU GPL v2 only. +# +# i3blocks blocklet script to play youtube videos from your clipboard using mpv + +use strict; +use warnings; +use utf8; +use Data::Validate::URI; + +my $cache_default = $ENV{CACHE_DEFAULT} || 1048576; +my $signal = $ENV{signal} || 1; +my $notify_i3bar = "pkill -RTMIN+$signal i3blocks"; +my $string = qx/xclip -out/; +$string =~ s/[';\\]//g; # remove characters that can cause i3-msg to crash +my $uriValidator = new Data::Validate::URI(); +my $BLOCK_BUTTON = $ENV{BLOCK_BUTTON} || 0; +my $PLAYING_COLOR = $ENV{PLAYING_COLOR} || "red"; +my $NOT_PLAYING_COLOR = $ENV{PLAYING_COLOR} || "white"; +my $USER = $ENV{USER}; +my $i3cmd = ""; +my $i3cmdexitstatus = 0; + +if ($uriValidator->is_web_uri($string) or $BLOCK_BUTTON == 3) { + if ($BLOCK_BUTTON == 1) { + $i3cmd = "exec mpv --ytdl --cache-default=$cache_default --tls-verify '$string' && $notify_i3bar"; + } elsif ($BLOCK_BUTTON == 2) { + $i3cmd = "exec mpv --ytdl --tls-verify --ytdl-format=bestaudio '$string' && $notify_i3bar"; + } elsif ($BLOCK_BUTTON == 3) { + $i3cmd = "exec killall -u $USER mpv && $notify_i3bar"; + } + + system("i3-msg", "-q", $i3cmd); + # i3-msg may return before mpv has started + sleep(.1); +} + +my $color; + +if (system("pgrep -x mpv 2>&1 1>/dev/null") == 0) { + $color = $PLAYING_COLOR; +} else { + $color = $NOT_PLAYING_COLOR; +} + +binmode(STDOUT, ":utf8"); +print("\x{f16a}\n"); +print("\x{f16a}\n"); diff --git a/.config/i3blocks/ytdl-mpv/ytdl-mpv.png b/.config/i3blocks/ytdl-mpv/ytdl-mpv.png new file mode 100644 index 0000000..e61d3f0 Binary files /dev/null and b/.config/i3blocks/ytdl-mpv/ytdl-mpv.png differ diff --git a/.config/mako/config b/.config/mako/config new file mode 100644 index 0000000..b59fb6f --- /dev/null +++ b/.config/mako/config @@ -0,0 +1,5 @@ + +default-timeout=10000 +background-color=#9966CCEE +border-color=#CC88FFFF +font=sans-serif 10 diff --git a/.config/sway/config b/.config/sway/config new file mode 100644 index 0000000..ff202ab --- /dev/null +++ b/.config/sway/config @@ -0,0 +1,298 @@ + +### Variables +# +# Logo key. Use Mod1 for Alt. +set $mod Mod1 +# Home row direction keys, like vim +set $left h +set $down j +set $up k +set $right l +# Your preferred terminal emulator +set $term alacritty +# lock command +set $lock ~/.local/bin/lock +# file manager +set $fm nnn + +# Your preferred application launcher +# Note: it's recommended that you pass the final command to sway +set $menu dmenu_path | ~/.local/bin/bomenu -p '' | xargs swaymsg exec + +# window borders +default_border pixel 1 +hide_edge_borders smart + +# Notification daemon +exec mako +exec pulseaudio + +### Output configuration +# +# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/) + + output * bg "/home/odrling/Pictures/Wallpapers/anime-emotion-crowd-laughter-surprise-girls-emotional-wallpapers-wallpaper-leukjs6k.jpg" fill + +# +# Example configuration: +# + + output HDMI-A-1 pos 1366,0 + output eDP-1 res 1366x768 pos 0 0 + +# +# You can get the names of your outputs by running: swaymsg -t get_outputs + +### Idle configuration +# +# Example configuration: +# +exec idle + +# This will lock your screen after 300 seconds of inactivity, then turn off +# your displays after another 300 seconds, and turn your screens back on when +# resumed. It will also lock your screen before your computer goes to sleep. + +### Input configuration +# +# Example configuration: +# + input "2:14:ETPS/2_Elantech_Touchpad" { + tap enabled + natural_scroll enabled + tap_button_map lrm + } +# +# You can get the names of your inputs by running: swaymsg -t get_inputs +# Read `man 5 sway-input` for more information about this section. +# + + input * xkb_layout "fr" + +### Key bindings +# +# Basics: +# + # start a terminal + bindsym $mod+Return exec $term + bindsym $mod+f exec firefox + bindsym $mod+g exec webmenu + bindsym $mod+d exec discord + bindsym $mod+m exec $term -e ncmpcpp + bindsym $mod+Shift+m exec thunderbird + bindsym $mod+p exec passmenu + bindsym $mod+a exec $term -e anime + bindsym $mod+v exec $term -e vid + bindsym $mod+c exec $term -e python + bindsym $mod+t exec $term -e htop + bindsym $mod+n exec $term -e $fm + bindsym $mod+i exec $term -e newsboat + +# see mpv screenshots + set $path ~/Pictures/mpv + bindsym $mod+s exec sxiv -t $path + + # kill focused window + bindsym $mod+q kill + + # start your launcher + bindsym $mod+o exec $menu + + # Drag floating windows by holding down $mod and left mouse button. + # Resize them with right mouse button + $mod. + # Despite the name, also works for non-floating windows. + # Change normal to inverse to use left mouse button for resizing and right + # mouse button for dragging. + floating_modifier $mod normal + + # reload the configuration file + bindsym $mod+Shift+c reload + + # exit sway (logs you out of your Wayland session) + bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit' +# +# Moving around: +# + # Move your focus around + bindsym $mod+$left focus left + bindsym $mod+$down focus down + bindsym $mod+$up focus up + bindsym $mod+$right focus right + # or use $mod+[up|down|left|right] + bindsym $mod+Left focus left + bindsym $mod+Down focus down + bindsym $mod+Up focus up + bindsym $mod+Right focus right + + # _move_ the focused window with the same, but add Shift + bindsym $mod+Shift+$left move left + bindsym $mod+Shift+$down move down + bindsym $mod+Shift+$up move up + bindsym $mod+Shift+$right move right + # ditto, with arrow keys + bindsym $mod+Shift+Left move left + bindsym $mod+Shift+Down move down + bindsym $mod+Shift+Up move up + bindsym $mod+Shift+Right move right +# +# Workspaces: +# + ## switch to workspace + #bindsym $mod+1 workspace 1 + #bindsym $mod+2 workspace 2 + #bindsym $mod+3 workspace 3 + #bindsym $mod+4 workspace 4 + #bindsym $mod+5 workspace 5 + #bindsym $mod+6 workspace 6 + #bindsym $mod+7 workspace 7 + #bindsym $mod+8 workspace 8 + #bindsym $mod+9 workspace 9 + #bindsym $mod+0 workspace 10 + + # move focused container to workspace + #set $move "move_window" + #mode "$move" { + #bindsym $mod+1 move container to workspace 1 + #bindsym $mod+2 move container to workspace 2 + #bindsym $mod+3 move container to workspace 3 + #bindsym $mod+4 move container to workspace 4 + #bindsym $mod+5 move container to workspace 5 + #bindsym $mod+6 move container to workspace 6 + #bindsym $mod+7 move container to workspace 7 + #bindsym $mod+8 move container to workspace 8 + #bindsym $mod+9 move container to workspace 9 + #bindsym $mod+0 move container to workspace 10 + # Note: workspaces can have any name you want, not just numbers. + # We just use 1-10 as the default. + #bindsym Escape mode "default" + #bindsym Return mode "default" + #} + #bindsym $mod+m mode "$move" + + bindsym $mod+ampersand workspace 1 + bindsym $mod+eacute workspace 2 + bindsym $mod+quotedbl workspace 3 + bindsym $mod+apostrophe workspace 4 + bindsym $mod+parenleft workspace 5 + bindsym $mod+minus workspace 6 + bindsym $mod+egrave workspace 7 + bindsym $mod+underscore workspace 8 + bindsym $mod+ccedilla workspace 9 + bindsym $mod+agrave workspace 10 + + bindsym $mod+Shift+ampersand move container to workspace 1 + bindsym $mod+Shift+eacute move container to workspace 2 + bindsym $mod+Shift+quotedbl move container to workspace 3 + bindsym $mod+Shift+apostrophe move container to workspace 4 + bindsym $mod+Shift+parenleft move container to workspace 5 + bindsym $mod+Shift+minus move container to workspace 6 + bindsym $mod+Shift+egrave move container to workspace 7 + bindsym $mod+Shift+underscore move container to workspace 8 + bindsym $mod+Shift+ccedilla move container to workspace 9 + bindsym $mod+Shift+agrave move container to workspace 10 + +# +# Layout stuff: +# + # You can "split" the current object of your focus with + # $mod+b or $mod+v, for horizontal and vertical splits + # respectively. + bindsym $mod+Shift+b splith + bindsym $mod+Shift+v splitv + + # Switch the current container between different layout styles + #bindsym $mod+Shift+s layout stacking + bindsym $mod+Shift+w layout tabbed + bindsym $mod+Shift+s layout toggle split + + # Make the current focus fullscreen + bindsym $mod+Shift+f fullscreen + + # Toggle the current focus between tiling and floating mode + bindsym $mod+Shift+space floating toggle + + # Swap focus between the tiling area and the floating area + bindsym $mod+space focus mode_toggle + + # move focus to the parent container + bindsym $mod+Shift+a focus parent +# +# Scratchpad: +# + # Sway has a "scratchpad", which is a bag of holding for windows. + # You can send windows there and get them back later. + + # Move the currently focused window to the scratchpad + #bindsym $mod+Shift+minus move scratchpad + + # Show the next scratchpad window or hide the focused scratchpad window. + # If there are multiple scratchpad windows, this command cycles through them. + #bindsym $mod+minus scratchpad show +# +# Resizing containers: +# +mode "resize" { + # left will shrink the containers width + # right will grow the containers width + # up will shrink the containers height + # down will grow the containers height + bindsym $left resize shrink width 10px + bindsym $down resize grow height 10px + bindsym $up resize shrink height 10px + bindsym $right resize grow width 10px + + # ditto, with arrow keys + bindsym Left resize shrink width 10px + bindsym Down resize grow height 10px + bindsym Up resize shrink height 10px + bindsym Right resize grow width 10px + + # return to default mode + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" + +# +# Status Bar: +# +# Read `man 5 sway-bar` for more information about this section. +bar { + position top + + # When the status_command prints a new line to stdout, swaybar updates. + # The default just shows the current date and time. + #status_command while date +'%Y-%m-%d %H:%M:%S'; do sleep 1; done + status_command i3blocks + font Aller 10 + + colors { + statusline #ffffff + background #333333 + inactive_workspace #32323200 #32323200 #5c5c5c + } +} + +# +# Special keys +# + bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% + bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% + bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle + bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle + bindsym XF86MonBrightnessDown exec xbacklight -dec 5 + bindsym XF86MonBrightnessUp exec xbacklight -inc 5 + + bindsym Mod4+l exec lock -f # pkill -USR1 swayidle + bindsym $mod+Shift+p exec powermenu + bindsym Mod4+b exec bluetoothctl power on + bindsym Mod4+Shift+b exec bluetoothctl power off + bindsym Mod4+c exec caffeine + + bindsym Mod4+p exec toggle_screen + bindsym Mod4+Shift+p exec swaymsg 'output eDP-1 dpms on' + + bindsym Print exec grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') - | wl-copy && notify-send 'Screenshot taken' 'Current screen in the clipboard' + bindsym Shift+Print exec grim -g "$(slurp)" - | wl-copy && notify-send 'Screenshot taken' 'Area in the clipboard' + bindsym Mod4+Print exec grim - | wl-copy && notify-send 'Screenshot taken' 'Full desktop in the clipboard' + diff --git a/.gitignore b/.gitignore index 254224d..a43be9d 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,12 @@ Cache # zsh modules !.zsh/ + +# sway +!/.config/sway + +# i3blocks +!/.config/i3blocks + +# mako +!/.config/mako diff --git a/.local/bin b/.local/bin index 023fd71..f08efcb 160000 --- a/.local/bin +++ b/.local/bin @@ -1 +1 @@ -Subproject commit 023fd7182c7ddab0db3e8b6856325a561c36d345 +Subproject commit f08efcb3d045f3ade9ebc342fdc68caa593b0582