diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 03089cc2..1526b518 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,24 +1,24 @@ # How to contribute -So you've written a blocklet for i3blocks and would like to share it with the +So you've written a blocklet for i3blocks and would like to share it with the community, great! Let's just set a few ground rules in order to get your -blocklet included. +blocklet included. -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", -"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", +"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt). # Directory guidelines -1. A blocklet MUST be confined to a single directory and the name of the +1. A blocklet MUST be confined to a single directory and the name of the directory MUST be relevant to the blocklet's purpose or core feature. 2. A blocklet MUST be human readable. 3. A blocklet MUST contain a `README.md` explaining what the blocklet does, what its dependencies are, and any special instruction or setup required to use it. -4. A suggested i3blocks configuration MUST be included in an `i3blocks.conf` +4. A suggested i3blocks configuration MUST be included in an `i3blocks.conf` file or within the `README.md`. -5. Any non-obvious assumptions required to make the configuration work SHOULD +5. Any non-obvious assumptions required to make the configuration work SHOULD be included either in the `README.md` or as comments in the configuration. 6. A blocklet's suggested command SHOULD be of the form `command=$SCRIPT_DIR/myscript [args...]` even @@ -26,11 +26,11 @@ interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt). using injected properties. 7. The command file (`myscript` above) SHOULD be the entirety of the executable part of your blocklet, i.e. your code is a single script. -8. The command file's name, SHOULD match the name of the +8. The command file's name, SHOULD match the name of the containing directory. E.g. `myscript/myscript` is a good name, but `myscript/yourscript` is not. 9. A blocklet SHOULD NOT have a separate non `i3blocks.conf` configuration - file. Any extra configuration (e.g. default colors, paths, etc.) SHOULD be + file. Any extra configuration (e.g. default colors, paths, etc.) SHOULD be injected properties. 10. A blocklet MUST include at least one screenshot of what it looks like in action. @@ -53,15 +53,15 @@ interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt). 2. A contributor with write access MUST NOT merge any pull request that he or she created, unless there are no other contributors with write access currently active. -3. Commit messages SHOULD be written in imperative form. E.g. +3. Commit messages SHOULD be written in imperative form. E.g. `myscript: add option to configure colors`, instead of `myscript: added option to configure colors`. -4. Commit message first lines SHOULD be 72 characters or less but descriptive, +4. Commit message first lines SHOULD be 72 characters or less but descriptive, and details MAY be added to subsequent lines. 5. Commit details SHOULD write `Fixes: [issue]` or `Closes: [issue]` if the commit is meant to fix/close an issue on the issues page. 6. A pull request SHOULD contribute significant change to exactly one - blocklet. A bug fix or new injected property will usually be considered + blocklet. A bug fix or new injected property will usually be considered a significant change. # Example workflow @@ -69,34 +69,34 @@ interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt). In case you have never made a pull request before, here is an example workflow. 1. You write and test your blocklet called `myscript`. -2. You write a `README.md` and `i3blocks.conf` to go with your script, make a - `screenshot.png` and put `myscript`, `README.md`, `i3blocks.conf`, +2. You write a `README.md` and `i3blocks.conf` to go with your script, make a + `screenshot.png` and put `myscript`, `README.md`, `i3blocks.conf`, `screenshot.png`, and your favorite `LICENSE` into a directory called `myscript`. 3. You fork the i3blocks-contrib repository on github, and clone your fork of i3blocks-contrib onto your computer with `git clone [your fork here]`. 4. You copy your `myscript` directory to the top level of the cloned i3blocks-contrib directory and `cd` to the top level directory. -5. You `git add myscript` to tell git to track your blocklet's directory, you +5. You `git add myscript` to tell git to track your blocklet's directory, you will need to do this before every commit. 6. You `git commit` and leave a commit message of the form `myscript: add myscript, a short description of myscript` 7. Perhaps you make a few last minute changes, and add another commit. 8. You squash your commits into one with `git rebase -i` and follow the - instructions, leaving only your first commit and commits that were already + instructions, leaving only your first commit and commits that were already there unsquashed. 9. You push your changes to your fork on github with `git push`. 10. You navigate to vivien's i3blocks-contrib, click "pull requests" and - "New pull request". You click "compare across forks", then select the base - as vivien's i3blocks-contrib and the head fork as yours. You click + "New pull request". You click "compare across forks", then select the base + as vivien's i3blocks-contrib and the head fork as yours. You click "Create pull request". -11. The community makes some comments and suggests some things to improve before +11. The community makes some comments and suggests some things to improve before your blocklet is accepted. -12. You add and commit changes to your local copy, and then squash them as before, so +12. You add and commit changes to your local copy, and then squash them as before, so that there are only two commits besides those that were there when you first - forked, your initial commit and one representing all the changes made to + forked, your initial commit and one representing all the changes made to address community concerns. -13. You push to your remote fork of i3blocks-contrib, and the changes +13. You push to your remote fork of i3blocks-contrib, and the changes automatically get incorporated into the pull request process. 14. A maintainer with write access to vivien's i3blocks-contrib decides your script is ready to be merged and merges it in, possibly making minor changes @@ -107,7 +107,7 @@ squash your local commits since your last pull request and replace the commit message with something of the form myscript: what has changed since last pull request - + More detailed description of changes, perhaps including: Change 1 Change 2 diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..0c6090a8 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +PREFIX = $(HOME)/.local/ + +_INSTALLDIR = $(DESTDIR)$(PREFIX)/libexec/i3blocks/ + +_MAKEBLOCKS := $(dir $(wildcard */Makefile)) +all: build +build: $(_MAKEBLOCKS) +$(_MAKEBLOCKS): + $(MAKE) -C $@ + +install: all do-install + +installdirs: + install -d $(_INSTALLDIR) + +_BLOCKS := $(shell find . -type f -executable -not -path './.*') + +do-install: installdirs $(_BLOCKS) +$(_BLOCKS): + install -m755 $@ $(_INSTALLDIR) + +uninstall: + rm -f $(foreach block,$(_BLOCKS),$(_INSTALLDIR)$(notdir $(block))) + +.PHONY: $(_MAKEBLOCKS) $(_BLOCKS) build do-install all install uninstall diff --git a/README.adoc b/README.adoc index a6d3b65d..652d30db 100644 --- a/README.adoc +++ b/README.adoc @@ -8,9 +8,11 @@ This repository contains a set of scripts (a.k.a. *blocklets*) for link:https:// | link:apt-upgrades[] | Show system upgrades using aptitude | link:arch-update[] | Show AUR updates using yaourt | link:aur-update[] | Show AUR updates +| link:backlight[] | Show the screen brightness value given by `xbacklight` | 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-poly[] | Show multi-battery info | link:battery[] | Show battery info | link:battery2[] | Pretty battery info | link:batterybar[] | Show battery info graphically as a bar @@ -22,12 +24,14 @@ This repository contains a set of scripts (a.k.a. *blocklets*) for link:https:// | link:docker[] | Show the number of Docker containers and container IP | link:dunst[] | Toggle Dunst notifications using a simple Do-Not-Disturb button | link:email[] | Show the number of unread IMAP messages -| link:essid[] | Show the wifi ESSID you are connected to +| link:essid[] | Show the wifi ESSID you are connected to (dep: iwconfig, perl) | link:gpu-load[] | Shows load of Nvidia GPUs +| link:go[] | Show the currently installed Go version | 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:key_light[] | Control the keyboard backlight | 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 @@ -40,6 +44,7 @@ This repository contains a set of scripts (a.k.a. *blocklets*) for link:https:// | 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:ssid[] | Show the wifi SSID you are connected to (dep: iw, awk) | 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 diff --git a/arch-update/arch-update b/arch-update/arch-update index 59044ede..8ee18f36 100755 --- a/arch-update/arch-update +++ b/arch-update/arch-update @@ -62,7 +62,14 @@ def create_argparse(): def get_updates(): - output = check_output(['checkupdates']).decode('utf-8') + output = '' + try: + output = check_output(['checkupdates']).decode('utf-8') + except subprocess.CalledProcessError as exc: + # checkupdates exits with 2 and no output if no updates are available. + # we ignore this case and go on + if not (exc.returncode == 2 and not exc.output): + raise exc if not output: return [] @@ -112,8 +119,13 @@ if args.aur: update_count = len(updates) if update_count > 0: - info = str(update_count) + ' updates available' - short_info = str(update_count) + ' updates' + if update_count == 1: + info = str(update_count) + ' update available' + short_info = str(update_count) + ' update' + else: + 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)) diff --git a/aur-update/README.md b/aur-update/README.md index 7124dd7f..98e37832 100644 --- a/aur-update/README.md +++ b/aur-update/README.md @@ -12,14 +12,18 @@ Example i3blocks configuration: [aur-update] command=$SCRIPT_DIR/aur-update markup=pango +format=json interval=43200 UPDATE_COLOR=red QUIET=1 IGNORE=root vidyodesktop +#CACHE_UPDATES=0 ``` Right or middle click sends a notification (via notify-send) with a list of outdated packages and the corresponding version information. +If you enable caching (`CACHE_UPDATES=1`), the update list will be cached as an environment variable. +This will be read on a (right/middle) click to directly show the notification without the delay caused by updating the list. ## Dependencies diff --git a/aur-update/aur-update b/aur-update/aur-update index eb22ef0e..6fdd7dc5 100755 --- a/aur-update/aur-update +++ b/aur-update/aur-update @@ -17,6 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import json import os import requests import subprocess as sp @@ -41,6 +42,7 @@ args = Args() args.add_argument('UPDATE_COLOR', 'yellow') args.add_argument('QUIET', False, bool) args.add_argument('IGNORE', [], list) +args.add_argument('CACHE_UPDATES', False, bool) def version_in_aur(pkg): @@ -74,6 +76,14 @@ def vcs_version(pkg, ver): return None +# show the list of updates already cached +if args.cache_updates and block_button in [2, 3]: + if '_update_cache' in os.environ: + updates = os.environ['_update_cache'] + else: + updates = 'no updates cached' + sp.call(['notify-send', 'AUR updates', updates or 'up to date']) + # get list of foreign packages -- assumed to be from the AUR packages = sp.check_output(['pacman', '-Qm']).decode('utf8') @@ -93,15 +103,25 @@ for pkg in installed_version.keys(): if vcs_version(pkg, v_aur) != vcs_version(pkg, v_inst): updates.append(pkg + ' (%s -> %s)' % (v_inst, v_aur)) +# create the message for the block n_updates = len(updates) if n_updates > 0: - msg = "{1} AUR updates" - print(msg.format(args.update_color, n_updates)) + msg = "{1} AUR updates".format(args.update_color, n_updates) elif not args.quiet: - print('AUR up to date') + msg = 'AUR up to date' + +# turn it into a json message +msg = {'full_text': msg} + +# cache the new updates list +if args.cache_updates: + msg['_update_cache'] = '\n'.join(updates) + +print(json.dumps(msg)) -if block_button in [2, 3]: - sp.call(['notify-send', 'AUR updates', '\n'.join(updates)]) +# if you don't use caching, show the new list of updates +if not args.cache_updates and block_button in [2, 3]: + sp.call(['notify-send', 'AUR updates', '\n'.join(updates) or 'up to date']) if not 'BLOCK_NAME' in os.environ and n_updates > 0: # not called by i3blocks: show the complete list diff --git a/backlight/LICENSE.md b/backlight/LICENSE.md new file mode 100644 index 00000000..5f8b06fe --- /dev/null +++ b/backlight/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/backlight/README.md b/backlight/README.md new file mode 100644 index 00000000..a2388296 --- /dev/null +++ b/backlight/README.md @@ -0,0 +1,50 @@ +# backlight + +Show the screen brightness value given by `xbacklight`. +Clicking uses `xset` to turn off the backlight, scrolling increases or decreases +the brightness. + +![](example.png) + +## Setup / Usage + +Example i3blocks configuration: + +``` +[backlight] +command=$SCRIPT_DIR/backlight +label=☀ +interval=20 +#STEP_SIZE=5 +#USE_SUDO=0 +``` + +- right click: turn off backlight +- scroll: increase/decrease the brightness in percentage steps according to `STEP_SIZE` + +## Dependencies + +These tools from the xorg-suite are needed: + +- `xorg-xbacklight` +- `xorg-xset` + +You need to allow the user to change the brightness (only if you want to use scrolling). +If you don't have the proper permissions, you will get an error like + +```bash session +$ xbacklight -inc 5 +/usr/bin/xbacklight: [Errno 13] Permission denied: '/sys/class/backlight/intel_backlight/brightness' +``` + +One option is to create a [udev rule](https://wiki.archlinux.org/index.php/Backlight#Udev_rule). + +Another option is to allow the user to execute `xbacklight` without a password using the +[sudoers file](https://wiki.archlinux.org/index.php/Sudo#Configuration). +For the user `` it would be something like + +``` + ALL=(ALL) NOPASSWD: /usr/bin/xbacklight +``` + +Then use `USE_SUDO=1` in the configuration of this block. diff --git a/backlight/backlight b/backlight/backlight new file mode 100755 index 00000000..67cfb2ce --- /dev/null +++ b/backlight/backlight @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Show the screen brightness value given by `xbacklight`. +# Clicking uses `xset` to turn off the backlight, scrolling increases or decreases +# the brightness. + +# Copyright 2019 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 . + + +STEP_SIZE=${STEP_SIZE:-5} +USE_SUDO=${USE_SUDO:-0} + +# whether to use `sudo` for changing the brightness (requires a NOPASSWD rule) +if [[ "$USE_SUDO" == "0" ]] ; then + XBACKLIGHT_SET="xbacklight" +else + XBACKLIGHT_SET="sudo xbacklight" +fi + +case $BLOCK_BUTTON in + 3) xset dpms force off ;; # right click + 4) $XBACKLIGHT_SET -inc "$STEP_SIZE" ;; # scroll up + 5) $XBACKLIGHT_SET -dec "$STEP_SIZE" ;; # scroll down, decrease +esac + + +BRIGHTNESS=$(xbacklight -get | cut -f1 -d'.') +echo "${BRIGHTNESS}%" diff --git a/backlight/example.png b/backlight/example.png new file mode 100644 index 00000000..3e435df9 Binary files /dev/null and b/backlight/example.png differ diff --git a/bandwidth/bandwidth b/bandwidth/bandwidth index 6a93c35c..9427973d 100755 --- a/bandwidth/bandwidth +++ b/bandwidth/bandwidth @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright (C) 2012 Stefan Breunig # Copyright (C) 2014 kaueraal # Copyright (C) 2015 Thiago Perrotta diff --git a/bandwidth2/bandwidth2.c b/bandwidth2/bandwidth2.c index 2ce75b65..d354b4ba 100644 --- a/bandwidth2/bandwidth2.c +++ b/bandwidth2/bandwidth2.c @@ -94,7 +94,7 @@ void display(int const unit, int const divisor, if (unit == 'b') b = b * 8; - snprintf(fmtstr, sizeof (fmtstr), "%%%d.1lf ", divisor > 1000 ? 6 : 5); + snprintf(fmtstr, sizeof (fmtstr), "%%%d.1lf", divisor > 1000 ? 6 : 5); if (b < divisor) { printf(fmtstr, b); diff --git a/battery-poly/LICENSE b/battery-poly/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/battery-poly/LICENSE @@ -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/battery-poly/README.md b/battery-poly/README.md new file mode 100644 index 00000000..62d79f3c --- /dev/null +++ b/battery-poly/README.md @@ -0,0 +1,37 @@ +# battery-poly +Generates a pretty battery string for multi-battery systems. Based on [cogitantium/poly-battery-status-py](https://github.com/cogitantium/poly-battery-status-py). Licensed under GPLv3. + +![](battery-poly.png) + +## Features +- Uses sysfs for gathering batteries and values on these +- Calculates time-to-depleted and time-to-full from current power-draw +- Takes battery-thresholds, such as [TLP](https://github.com/linrunner/TLP), into account when calculating time-to-**full**. Defaults to 100% but is overrideable through arguments. +- Omits time-to-* when passive (specifically when sysfs delivers a status of `Unknown` or `Full`) +- Takes a Python formatting string for percentage. Default is `.2%` rendering a percentage with two decimals. + +## Dependencies +- python3 +- sysfs (provided by Linux kernel since 2.5) + +## Config +``` +[battery-poly] +command=$SCRIPT_DIR/battery-poly +LABEL=BAT +interval=5 +``` + +Two positional arguments are supported; battery-threshold as float and percentage formatting as Python formatting string. + +To configure battery-poly for a battery-threshold of 42%, edit the `command`-line as such: +``` +[battery-poly] +command=$SCRIPT_DIR/battery-poly 0.42 +``` + +If no decimals are desired for the percentage and battery-threshold is not to be changed, simply put the default value as follows: +``` +[battery-poly] +command=$SCRIPT_DIR/battery-poly 1.0 .0% +``` \ No newline at end of file diff --git a/battery-poly/battery-poly b/battery-poly/battery-poly new file mode 100755 index 00000000..15ddafde --- /dev/null +++ b/battery-poly/battery-poly @@ -0,0 +1,168 @@ +#!/usr/bin/env python3 +""" +poly-battery-status-py: Generates a pretty status-bar string for multi-battery systems on Linux. +Copyright (C) 2020 Falke Carlsen + +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 re +import sys +from enum import Enum +from pathlib import Path + +PSEUDO_FS_PATH = "/sys/class/power_supply/" +CURRENT_CHARGE_FILENAME = "energy_now" +MAX_CHARGE_FILENAME = "energy_full" +POWER_DRAW_FILENAME = "power_now" +TLP_THRESHOLD_PERCENTAGE = 1.0 +PERCENTAGE_FORMAT = ".2%" + +if len(sys.argv) > 1: + # parsing threshold + try: + TLP_THRESHOLD_PERCENTAGE = float(sys.argv[1]) + except ValueError: + print(f"[ERROR]: Could not convert '{sys.argv[1]}' into a float.") + if len(sys.argv) > 2: + # parsing formatting + PERCENTAGE_FORMAT = sys.argv[2] + + +class Status(Enum): + CHARGING = 1 + DISCHARGING = 2 + PASSIVE = 3 + + +class Configuration: + time_to_completion: int + percentage: float + status: Status + + def __init__(self, time_to_completion, percentage, status): + self.time_to_completion = time_to_completion + self.percentage = percentage + self.status = status + + +class Battery: + status: Status + current_charge: int + max_charge: int + power_draw: int + + def __init__(self, status, current_charge, max_charge, power_draw): + self.Status = status + self.current_charge = current_charge + self.max_charge = max_charge + self.power_draw = power_draw + + +def get_configuration() -> Configuration: + # get all batteries on system + batteries = [] + for x in Path(PSEUDO_FS_PATH).iterdir(): + bat_name = str(x.parts[len(x.parts) - 1]) + if re.match("^BAT\d+$", bat_name): + batteries.append(Battery( + get_status(bat_name), + get_current_charge(bat_name), + get_max_charge(bat_name), + get_power_draw(bat_name))) + + # calculate global status, assumes that if a battery is not passive, it will be discharging or charging + config_status = Status.PASSIVE + for bat in batteries: + if bat.Status == Status.CHARGING: + config_status = Status.CHARGING + break + elif bat.Status == Status.DISCHARGING: + config_status = Status.DISCHARGING + break + + # construct and return configuration + return Configuration(calc_time(batteries, config_status), calc_percentage(batteries), config_status) + + +def get_status(bat_name: str) -> Status: + raw_status = Path(f"{PSEUDO_FS_PATH}{bat_name}/status").open().read().strip() + if raw_status == "Unknown" or raw_status == "Full": + return Status.PASSIVE + elif raw_status == "Charging": + return Status.CHARGING + elif raw_status == "Discharging": + return Status.DISCHARGING + else: + raise ValueError + + +def get_current_charge(bat_name: str) -> int: + return int(Path(f"{PSEUDO_FS_PATH}{bat_name}/{CURRENT_CHARGE_FILENAME}").open().read().strip()) + + +def get_max_charge(bat_name: str) -> int: + return int(Path(f"{PSEUDO_FS_PATH}{bat_name}/{MAX_CHARGE_FILENAME}").open().read().strip()) + + +def get_power_draw(bat_name: str) -> int: + return int(Path(f"{PSEUDO_FS_PATH}{bat_name}/{POWER_DRAW_FILENAME}").open().read().strip()) + + +def calc_time(batteries: list, status: Status) -> int: + if status == Status.PASSIVE: + return 0 + # get total metrics on configuration + total_current_charge = sum([bat.current_charge for bat in batteries]) + total_max_charge = sum([bat.max_charge for bat in batteries]) + total_power_draw = sum([bat.power_draw for bat in batteries]) + if status == Status.DISCHARGING: + # return number of seconds until empty + return (total_current_charge / total_power_draw) * 3600 + elif status == Status.CHARGING: + # return number of seconds until (optionally relatively) charged + return (((total_max_charge * TLP_THRESHOLD_PERCENTAGE) - total_current_charge) / total_power_draw) * 3600 + + +def calc_percentage(batteries: list) -> float: + total_max_charge = sum([bat.max_charge for bat in batteries]) + total_current_charge = sum([bat.current_charge for bat in batteries]) + return total_current_charge / total_max_charge + + +def calc_display_time(status: Status, seconds: int) -> str: + hours = int(seconds // 3600) + minutes = int((seconds % 3600) / 60) + if status == Status.PASSIVE: + return "" + + # assume charging initially if not passive + direction = "+" + if status == Status.DISCHARGING: + direction = "-" + + # format output digitally, e.g. (+0:09) + return f" ({direction}{hours}:{minutes:02})" + + +def print_status(config: Configuration): + print(f"{config.percentage:{PERCENTAGE_FORMAT}}{calc_display_time(config.status, config.time_to_completion)}") + + +def main(): + print_status(get_configuration()) + + +if __name__ == '__main__': + main() diff --git a/battery-poly/battery-poly.png b/battery-poly/battery-poly.png new file mode 100644 index 00000000..e0c548a0 Binary files /dev/null and b/battery-poly/battery-poly.png differ diff --git a/battery/battery b/battery/battery index b5f0a576..9b796b5f 100755 --- a/battery/battery +++ b/battery/battery @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Copyright 2014 Pierre Mavro # Copyright 2014 Vivien Didelot diff --git a/brightness/LICENSE b/brightness/LICENSE new file mode 100644 index 00000000..8c3d9764 --- /dev/null +++ b/brightness/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Oleg Katkov + +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/brightness/Makefile b/brightness/Makefile new file mode 100644 index 00000000..07a0cc77 --- /dev/null +++ b/brightness/Makefile @@ -0,0 +1,63 @@ +CC=gcc +AS=as +LD=ld +OBJDUMP=objdump +OBJCOPY=objcopy +SIZE=size +LINK=$(CC) + +BUILD_DIR=build +OBJ_DIR=$(BUILD_DIR)/obj +BIN_DIR=bin + +LIBS := +DEFS := -DVERSION=\"0.1\" +WARN_LEVEL = -Wall -Wextra -pedantic + +PRG = brightness +INCLUDES := -Iinc +CFLAGS := $(INCLUDES) $(DEFS) $(WARN_LEVEL) -pipe -O0 -g3 -std=c11 + +debug: CFLAGS += -O0 -g3 +debug: all + +release: CFLAGS += -O2 +release: all +LDFLAGS = $(LIBS) -ffunction-sections -Wl,--gc-sections + +SRC_C := $(wildcard *.c) $(wildcard src/*.c) +SRC_A := $(wildcard src/*.s) + +OBJECTS := $(SRC_C:%.c=$(OBJ_DIR)/%.o) +OBJECTS += $(SRC_A:%.s=$(OBJ_DIR)/%.o) + +all: directories $(PRG) + +$(PRG): $(BIN_DIR)/$(PRG) + +$(OBJ_DIR)/%.o: %.s + @mkdir -p $(@D) + $(AS) $(INCLUDES) $(MMCU) -g -o $@ $^ + +$(OBJ_DIR)/%.o: %.c + @mkdir -p $(@D) + $(CC) $(CFLAGS) -o $@ -c $< + +$(BIN_DIR)/$(PRG): $(OBJECTS) + @mkdir -p $(@D) + $(LINK) -o $(BIN_DIR)/$(PRG) $^ $(LDFLAGS) $(LIBS) + +.PHONY: directories +directories: + @mkdir -p $(BUILD_DIR) + @mkdir -p $(BIN_DIR) + +.PHONY: clean +clean: + @rm -rf $(BUILD_DIR)/* + @rm -rf $(BIN_DIR)/* + +.PHONY: mrproper +mrproper: + @rm -rf $(BUILD_DIR) + @rm -rf $(BIN_DIR) diff --git a/brightness/README.md b/brightness/README.md new file mode 100644 index 00000000..371a96da --- /dev/null +++ b/brightness/README.md @@ -0,0 +1,41 @@ +# brightness + +## Description + +This small tool listens to file "actual_brightness" modification and reports current brightness percentage. Written in C. It can be used with i3blocks persistent block. + +![Screenshot](brightness.png) + +## How to build + +`make release` + +The result executable will be placed into bin directory. + +## Config + +``` +[brightness] +command=./brightness/bin/brightness -a /sys/class/backlight/intel_backlight/actual_brightness -m /sys/class/backlight/intel_backlight/max_brightness +interval=persist +``` + +## Usage + +``` +brightness 0.1 - read actual brightness value in non-blocking style. + +Usage: brightness [options] + + Options: + -a, --actual_brightness_path path to file with actual brightness string + -m, --max_brightness_path path to file with max brightness string + -h, --help print this help. + -V, --version print version and exit. + +``` + +## Roadmap + +- [x] Connect tool with i3blocks +- [ ] Remove full paths from command arguments. Make it possible to set class or device and parse full path automatically via "/sys/brightness" or "/sys/leds". diff --git a/brightness/brightness.png b/brightness/brightness.png new file mode 100644 index 00000000..53799900 Binary files /dev/null and b/brightness/brightness.png differ diff --git a/brightness/main.c b/brightness/main.c new file mode 100644 index 00000000..3677dbda --- /dev/null +++ b/brightness/main.c @@ -0,0 +1,199 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define INOTIFY_EVENT_SIZE (sizeof (struct inotify_event)) +#define INOTIFY_BUFF_SIZE 64 + +static bool get_float_value_from_file(const char *path, + float *dst_val); + +static void print_brightness_percent(const char *actual_path, + const char *max_path); + +static void usage(void) { + fprintf(stderr, "brightness %s - read actual brightness value in non-blocking style.\n\n", VERSION); + fprintf(stderr, + "Usage: brightness [options]\n\ + \n\ + Options:\n\ + -a, --actual_brightness_path \tpath to file with actual brightness string\n\ + -m, --max_brightness_path \tpath to file with max brightness string\n\ + -h, --help \tprint this help.\n\ + -V, --version \tprint version and exit.\n\ + \n"); +} +////////////////////////////////////////////////////////////// + +int +main(int argc, char *argv[]) { + static const char *default_abp = "/sys/class/backlight/intel_backlight/actual_brightness"; + static const char *default_mbp = "/sys/class/backlight/intel_backlight/max_brightness"; + char *actual_brightness_path = default_abp; + char *max_brightness_path = default_mbp; + + char buff[INOTIFY_BUFF_SIZE] = {0}; + fd_set read_descriptors; + struct timeval time_to_wait; + int ifd, wd, read_len, rc, opt_idx; + size_t opt_len; + // ifd - inotify_file_descriptor + // wd - inotify wait descriptor + // rc - result code + + static const struct option lopts[] = { + {"actual_brightness_path", required_argument, NULL, 'a'}, + {"max_brightness_path", required_argument, NULL, 'm'}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'V'}, + {NULL, 0, NULL, 0}, +}; + + while ((opt_idx = getopt_long(argc, argv, "a:m:hV", lopts, NULL)) != -1) { + switch (opt_idx) { + case 'a': + opt_len = strlen(optarg); + actual_brightness_path = malloc(opt_len + 1); + strcpy(actual_brightness_path, optarg); + break; + case 'm': + opt_len = strlen(optarg); + max_brightness_path = malloc(opt_len + 1); + strcpy(max_brightness_path, optarg); + break; + case 'h': + usage(); + return 0; + case 'V': + printf("%s\n", VERSION); + return 0; + default: + printf("something bad is happened. option index is out of bounds (%d %c)\n", opt_idx, (char)opt_idx); + return -1; + } + } + + print_brightness_percent(actual_brightness_path, + max_brightness_path); + + ifd = inotify_init(); + if (ifd == -1) { + perror("inotify init failed"); + return -1; + } + + wd = inotify_add_watch(ifd, actual_brightness_path, IN_MODIFY); + FD_ZERO (&read_descriptors); + FD_SET (ifd, &read_descriptors); + time_to_wait.tv_sec = 10; + time_to_wait.tv_usec = 0; + + while (1) { + fd_set tmp_set = read_descriptors; + rc = select(ifd+1, &tmp_set, NULL, NULL, &time_to_wait); + if (rc < 0) { + perror("select failed"); + break; + } + + if (rc == 0) { //timeout + continue; + } + + if (!FD_ISSET(ifd, &read_descriptors)) { + continue; + } + + read_len = read(ifd, (void*)buff, INOTIFY_BUFF_SIZE); + if (read_len < 0) { + perror("read failed"); + continue; + } + + for (int eix = 0; eix < read_len; ) { + struct inotify_event *event = (struct inotify_event*) &buff[eix]; + eix += INOTIFY_EVENT_SIZE + event->len; + if (!(event->mask & IN_MODIFY)) { + continue; + } + + print_brightness_percent(actual_brightness_path, + max_brightness_path); + } + } + + //actually when we receive some signal (like sigterm or something like that) + //we will be here. + + inotify_rm_watch(ifd, wd); + close(ifd); + + if (actual_brightness_path != default_abp) + free(actual_brightness_path); + if (max_brightness_path != default_mbp) + free(max_brightness_path); + return 0; +} +////////////////////////////////////////////////////////////// + +bool +get_float_value_from_file(const char *path, + float *dst_val) { +#define BUFF_SIZE 16 + char buff[BUFF_SIZE] = {0}; + FILE *f = fopen(path, "r"); + bool result = false; + if (f == NULL) { + perror("failed to open file"); + return false; + } + + do { + if (!(fread((void*) buff, 1, BUFF_SIZE, f))) { + perror("failed to read file"); + break; + } + + char *unused; + *dst_val = strtof(buff, &unused); + result = true; + } while (0); + + fclose(f); + return result; +} +////////////////////////////////////////////////////////////// + +void +print_brightness_percent(const char *actual_path, + const char *max_path) { + float curr, max; + const char *parr[] = {actual_path, max_path}; + float *farr[] = {&curr, &max}; + + for (size_t i = 0; i < 2; ++i) { + bool success = get_float_value_from_file(parr[i], farr[i]);\ + if (!success) { + printf("\xF0\x9F\x94\x86"); //brightness symbol 🔆 + printf(": NA\n"); + fflush(stdout); // because we use select(), ant it blocks stdout + return; + } + } + + printf("\xF0\x9F\x94\x86"); //brightness symbol 🔆 + printf(": %02.f%%\n", (curr / max) * 100.f); + fflush(stdout); // because we use select(), ant it blocks stdout +} +////////////////////////////////////////////////////////////// diff --git a/calendar/calendar b/calendar/calendar index 4ec7d813..1824af8f 100755 --- a/calendar/calendar +++ b/calendar/calendar @@ -1,4 +1,4 @@ -#! /bin/sh +#!/usr/bin/env sh WIDTH=${WIDTH:-200} HEIGHT=${HEIGHT:-200} diff --git a/colorpicker/LICENSE.md b/colorpicker/LICENSE.md new file mode 100644 index 00000000..660ee4ed --- /dev/null +++ b/colorpicker/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/colorpicker/README.md b/colorpicker/README.md new file mode 100644 index 00000000..bf614995 --- /dev/null +++ b/colorpicker/README.md @@ -0,0 +1,19 @@ +# colorpicker + +Minimal colorpicker blocklet. Left click to start and to pause. + +Requires [grabc](https://github.com/muquit/grabc) and [xdotool](https://archlinux.org/packages/community/x86_64/xdotool/). + +![](colorpicker.png) + +* Copy the script into your directory of choice, e.g. ~/.i3blocks/blocklets +* Give it execution permission (`chmod +x colorpicker`) +* Add the following blocklet to your i3blocks.conf: + +```ini +[colorpicker] +format=json +interval=1 +#IDLE_TEXT=CPICK +#IDLE_TEXT_COLOR=#FFFFFF +``` diff --git a/colorpicker/colorpicker b/colorpicker/colorpicker new file mode 100755 index 00000000..fcd671ef --- /dev/null +++ b/colorpicker/colorpicker @@ -0,0 +1,102 @@ +#!/usr/bin/env bash +###### Default environment variables ###### +IDLE_TEXT=${IDLE_TEXT:-CPICK} +IDLE_TEXT_COLOR=${IDLE_TEXT_COLOR:-#FFFFFF} + +###### Verify dependencies ###### +if ! command -v xdotool &> /dev/null || ! command -v grabc &> /dev/null; then + error 'xdotool and/or grabc is not available' + exit 1 +fi + +###### Functions ###### +error() { + echo Error: "$@" 1>&2 +} + +play_pause() { + $running && pause || play +} + +play() { + running=true + pickcolor +} + +pause() { + running=false + fgcolor="$IDLE_TEXT_COLOR" +} + +hash2hex() { + echo "${1/\#/0x}" +} + +subtract_colors() { + col1=$(hash2hex "$1") + col2=$(hash2hex "$2") + b1=$(( col1 % 0x000100 )) + g1=$(( (col1 % 0x010000 - b1) / 0x100 )) + r1=$(( (col1 % 0x1000000 - 0x100*g1 - b1) / 0x10000 )) + b2=$(( col2 % 0x000100 )) + g2=$(( (col2 % 0x010000 - b2) / 0x100 )) + r2=$(( (col2 % 0x1000000 - 0x100*g2 - b2) / 0x10000 )) + dr=$(( r2 - r1 )) + dg=$(( g2 - g1 )) + db=$(( b2 - b1 )) + echo $(( ${dr#-} + ${dg#-} + ${db#-} )) +} + +rgbcmybw=( + [0]='#ff0000' + [1]='#00ff00' + [2]='#0000ff' + [3]='#ffff00' + [4]='#ff00ff' + [5]='#00ffff' + [6]='#000000' + [7]='#ffffff') + +pickcolor() { + > /dev/null 2>&1 xdotool sleep 0.01 click 1 & + bgcolor=$(grabc 2> /dev/null) + col_diff_max=0 + col_diff=0 + for col in "${rgbcmybw[@]}"; do + col_diff=$(subtract_colors "$col" "$bgcolor") + if (( ${col_diff#-} > "$col_diff_max" )); then + fgcolor=$col + col_diff_max=${col_diff#-} + fi + done +} + +###### Initialize ###### +[[ ! -v running ]] && pause + +###### Click processing ###### +case $BLOCK_BUTTON in + 1 ) + play_pause + ;; +esac + +###### Update color ###### +if $running; then + pickcolor + bgcolorstring='"background":"'"$bgcolor"'"' +else + bgcolor="$IDLE_TEXT" + bgcolorstring= +fi + +###### Output ###### +cat << EOF +{"full_text":"$bgcolor",\ +"running":"$running",\ +"bgcolor":"$bgcolor",\ +"fgcolor":"$fgcolor",\ +"color":"$fgcolor",\ +$bgcolorstring\ +} +EOF diff --git a/colorpicker/colorpicker.png b/colorpicker/colorpicker.png new file mode 100644 index 00000000..5c1b6d49 Binary files /dev/null and b/colorpicker/colorpicker.png differ diff --git a/configure b/configure new file mode 100755 index 00000000..bc9191b2 --- /dev/null +++ b/configure @@ -0,0 +1,7 @@ +#!/bin/sh +set -ex +PREFIX=$(echo $1 | cut -d= -f 2) +if [ -n "$PREFIX" ] +then + sed -i "s;^PREFIX.*;PREFIX = $PREFIX;g" Makefile +fi diff --git a/cpu_usage/cpu_usage b/cpu_usage/cpu_usage index 44c1189d..9e051093 100755 --- a/cpu_usage/cpu_usage +++ b/cpu_usage/cpu_usage @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Copyright 2014 Pierre Mavro # Copyright 2014 Vivien Didelot diff --git a/cpu_util_detailed/LICENSE b/cpu_util_detailed/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/cpu_util_detailed/LICENSE @@ -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/cpu_util_detailed/README.md b/cpu_util_detailed/README.md new file mode 100644 index 00000000..38205dc7 --- /dev/null +++ b/cpu_util_detailed/README.md @@ -0,0 +1,85 @@ +# cpu_util_detailed + +Report detailed CPU utilization statistics. + +Reports detailed CPU utilization as in man(1) mpstat, pango markup is used to distinguish values with colors, always prints total usage as short text. Written in bash and awk. + +![block preview](cpu_util_detailed.png) + +## Recommended: + + * **mpstat** - Usually a part of **sysstat** package. If `mpstat` command is not available, the script will fall back to reading '/proc/stat' and '/proc/utime' and doing its' own calculations, which consumes more CPU time. + + * **awk** - Chances are high you have it, should be under the same name in your distro's package repository. Not used in a fallback method. + +## Required: + + * **bc** - Usually a part of the system core/base, should be under the same name in your distro's package repository. + +## i3blocks config example: + +```ini +[cpu_util_detailed] +command=$SCRIPT_DIR/cpu_util_detailed +label=CPU +markup=pango +interval=-2 +#report_time=5 +#stats=usr nice sys iowait +#format=%6.2f +#warn=80 +#usr_color=green +#nice_color=yellow +#sys_color=red +#iowait_color=grey +#irq_color=purple +#soft_color=violet +#steal_color=orange +#guest_color=cyan +#gnice_color=blue +#idle_color=white +#total_color=white +``` + +**interval** must be set in i3blocks.conf, can be any, refer to [i3blocks README](https://github.com/vivien/i3blocks#interval). + +**report_time** - time for gathering CPU statistics, refer to man(1) mpstat. If not set, determined based on **interval**: for 'repeat' and '-2' set to 5, for less or equal 2 set to 1, for more than 2 set to **interval** - 1. This can be used to determine blocklet refresh interval with **interval** set to 'repeat' or '-2'. + +**stats** - a space separated list of stats to be displayed in the desired order. Names are as per man(1) mpstat -u option without a '%' symbol. Full list: usr nice sys iowait irq soft steal guest gnice idle total. Defailt is 'usr nice sys iowait'. You may want to add e.g. 'guest' if you're running virtual machines. + +Colors of relevant stats: + +**usr_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'green'. + +**nice_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'yellow'. + +**sys_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'red'. + +**iowait_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'grey'. + +**irq_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'purple'. + +**soft_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'violet'. + +**steal_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'orange'. + +**guest_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'cyan'. + +**gnice_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'blue'. + +**idle_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'white'. + +**total_color** must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant color value. Default is 'white'. + +**format** - a format string for `printf`, example values: + + - '%6.2f' (default) will display every stat as `' 12.34'` + + - '%5.1f' will display every stat as `' 12.3'` + + - ':%5.2f' will display every stat as `':12.34'` + +**warn** - warning threshold, when reached urgent flag is set, default is '80'. + +## WARNING +No sanity checks for values set in i3blocks.conf are made inside the script. diff --git a/cpu_util_detailed/cpu_util_detailed b/cpu_util_detailed/cpu_util_detailed new file mode 100755 index 00000000..c9eaac55 --- /dev/null +++ b/cpu_util_detailed/cpu_util_detailed @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +# cpu_util_detailed +# Meant for usage as an i3blocks blocklet. +# It reports detailed CPU utilization in colors using pango markup. +# Written by skidnik +# Licensed under GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt +# +# Defaults if not set +interval=${interval:-0} # just in case it's started not by i3blocks +stats=${stats:-usr nice sys iowait} +format=${format:-%6.2f} +warn=${warn:-80} +declare -A colormap=( + [usr]=${usr_color:-green} + [nice]=${nice_color:-yellow} + [sys]=${sys_color:-red} + [iowait]=${iowait_color:-grey} + [irq]=${irq_color:-purple} + [soft]=${soft_color:-violet} + [steal]=${steal_color:-orange} + [guest]=${guest_color:-cyan} + [gnice]=${gnice_color:-blue} + [idle]=${idle_color:-white} + [total]=${total_color:-white} + ) +# If $report_time not set: +# Set it to $interval - 1, but not less than 1. +# If $interval is 'repeat' or -2 set report_time to 5. +if [[ -z $report_time ]]; then + if [[ "$interval" =~ ^-?[0-9]+$ ]]; + then + if [[ $interval -gt 2 ]]; then + report_time=$(( interval - 1 )) + elif [[ $interval == -2 ]]; then + report_time=5 + else + report_time=1 + fi + elif [[ $interval == repeat ]]; then + report_time=5 + fi +fi +# 'idle' is hardcoded as it's always required, no need to ask for it two times. +getstats=${stats//idle /} +# Get detailed CPU load as a set of variables with same names: +if _mpstat="$(command -v mpstat)" +then + declare $( ${_mpstat} -u "$report_time" 1 | sed -n '3,4p' | awk -v stats="$getstats idle" ' + BEGIN{ + split(stats, fields) + } + { + split($0, headers) + getline + split($0, values) + for (i in fields) { + for (j in headers) + if ( headers[j] ~ "^%" fields[i] ) { + printf "%s=%s\n", fields[i], values[j] + } + } + } + ') + total=$( bc <<<"scale=2; 100 - $idle" ) +else + # This is a fallback way for the case `mpstat` is not available + start_uptime=($(cat /proc/uptime)) + start=($(sed -n '1p' /proc/stat)) + sleep ${report_time} + end_uptime=($(cat /proc/uptime)) + end=($(sed -n '1p' /proc/stat)) + user_hz=$(getconf CLK_TCK) + num_cpus=$(nproc --all) + delta_time=$( bc <<<"scale=2; ${end_uptime[0]}-${start_uptime[0]}" ) + user_hz_time=$( bc <<<"$delta_time * $user_hz" ) + usr=$( bc <<<"scale=4; (${end[1]}-${start[1]})/$num_cpus/$user_hz_time*100" ) + nice=$( bc <<<"scale=4; (${end[2]}-${start[2]})/$num_cpus/$user_hz_time*100" ) + sys=$( bc <<<"scale=4; (${end[3]}-${start[3]})/$num_cpus/$user_hz_time*100" ) + idle=$( bc <<<"scale=4; (${end[4]}-${start[4]})/$num_cpus/$user_hz_time*100" ) + iowait=$( bc <<<"scale=4; (${end[5]}-${start[5]})/$num_cpus/$user_hz_time*100" ) + irq=$( bc <<<"scale=4; (${end[6]}-${start[6]})/$num_cpus/$user_hz_time*100" ) + soft=$( bc <<<"scale=4; (${end[7]}-${start[7]})/$num_cpus/$user_hz_time*100" ) + steal=$( bc <<<"scale=4; (${end[8]}-${start[8]})/$num_cpus/$user_hz_time*100" ) + guest=$( bc <<<"scale=4; (${end[9]}-${start[9]})/$num_cpus/$user_hz_time*100" ) + gnice=$( bc <<<"scale=4; (${end[10]}-${start[10]})/$num_cpus/$user_hz_time*100" ) + total=$( bc <<<"scale=4; ${end_uptime[1]}-${start_uptime[1]}" ) +fi +# Output stats with pango formatting in a defined order +for stat in $stats +do + # No other way to make format adjustable + # shellcheck disable=SC2059 + printf "$format" "${colormap[$stat]}" "${!stat}" +done +echo # trailing newline +# Short text +# shellcheck disable=SC2059 +printf "$format\n" "$total" +# Set urgent flag if over warn threshold +(( $( bc <<<"$total >= $warn" ) )) && exit 33 || : diff --git a/cpu_util_detailed/cpu_util_detailed.png b/cpu_util_detailed/cpu_util_detailed.png new file mode 100644 index 00000000..27a97be0 Binary files /dev/null and b/cpu_util_detailed/cpu_util_detailed.png differ diff --git a/cpu_util_detailed/i3blocks.conf b/cpu_util_detailed/i3blocks.conf new file mode 100644 index 00000000..f0bac6a8 --- /dev/null +++ b/cpu_util_detailed/i3blocks.conf @@ -0,0 +1,21 @@ +[cpu_util_detailed] +command=$SCRIPT_DIR/cpu_util_detailed +label=CPU +markup=pango +interval=-2 +#report_time=5 +#stats=usr nice sys iowait +#format=%6.2f +#warn=80 +#usr_color=green +#nice_color=yellow +#sys_color=red +#iowait_color=grey +#irq_color=purple +#soft_color=violet +#steal_color=orange +#guest_color=cyan +#gnice_color=blue +#idle_color=white +#total_color=white + diff --git a/dimmer/LICENSE.md b/dimmer/LICENSE.md new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/dimmer/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/dimmer/README.md b/dimmer/README.md new file mode 100644 index 00000000..9cf1ff51 --- /dev/null +++ b/dimmer/README.md @@ -0,0 +1,44 @@ +# dimmer +## Description + +Without dimmer: + +![screenshot](dimmer_off.png) + +With dimmer: + +![screenshot](dimmer_on.png) + +This script is not an independent blocklet and meant to use as filter with any +i3blocks blocklets. + +dimmer useful if your bar have light background color and you want to use +colored blocklets made for dark background. + +dimmer parses a blocket output, gets strings with hex color codes and reduces +it values to make colors darker. + +## Usage + +To use dimmer you should add it through pipe, e.g. you may keep following in +your i3blocks.conf: + +```ini +[dimmer] +# Global properties +command=(/usr/lib/i3blocks/$BLOCK_NAME ; echo) | $SCRIPT_DIR/dimmer +``` + +echo is required for properly support of some scripts that does not produce new +line symbol on the end of their output (like bandwidth blocklet). + +## Options + +By default dimmer will reduce color values to 50%. Also dimmer supports custom +brightness values in percents as an argument, e.g.: + +``` +dimmer 72 +``` + +This will reduce values to 72% of origin. diff --git a/dimmer/dimmer b/dimmer/dimmer new file mode 100755 index 00000000..e2e72758 --- /dev/null +++ b/dimmer/dimmer @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# dimmer is a script that changes hex color codes to reduce brightness +# 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 . + +brightness=50 + +if [ -n "$1" ] ; then + brightness=$1 +fi + +shopt -s nocasematch + +while read -r line +do + + if + ! [[ $brightness =~ ^[0-9]+$ ]] || \ + [ "$brightness" -lt 0 ] || \ + [ "$brightness" -gt 100 ] + then + >&2 echo "dimmer: Invalid brightness value" + exit 1 + fi + + if [ ${#line} -eq 7 ] && [ "${line:0:1}" = "#" ] &&\ + [[ ${line:1:6} =~ ^[0-9A-F]{6}$ ]] + then + if [ "${brightness}" -eq 0 ] + then + # shellcheck disable=SC2016 + line='$000000' + else + colors=("0x${line:1:2}" "0x${line:3:2}" "0x${line:5:2}") + line='#' + for color in "${colors[@]}"; do + value=$(((color + (100 / brightness - 1)) * brightness / 100)) + color=$(echo "obase=16; ${value}" | bc) + + # If <= 9 supplement with 0. + if [ ${#color} -lt 2 ] ; then + color="0${color}" + fi + + line="$line$color" + done + fi + fi + + echo "$line" +done diff --git a/dimmer/dimmer_off.png b/dimmer/dimmer_off.png new file mode 100644 index 00000000..66ade84f Binary files /dev/null and b/dimmer/dimmer_off.png differ diff --git a/dimmer/dimmer_on.png b/dimmer/dimmer_on.png new file mode 100644 index 00000000..17fb70c2 Binary files /dev/null and b/dimmer/dimmer_on.png differ diff --git a/disk-io/disk-io b/disk-io/disk-io index b6bebc2f..daf8e586 100755 --- a/disk-io/disk-io +++ b/disk-io/disk-io @@ -18,6 +18,7 @@ threshold="${THRESHOLD:-0}" warn_color="${WARN_COLOR:-#FF0000}" sep="${SEPARATOR:-/}" unit_suffix="${SUFFIX:-B/s}" +align="${ALIGN--}" function list_devices { echo "Devices iostat reports that match our regex:" @@ -71,10 +72,10 @@ iostat -dyz "$dt" | awk -v sep="$sep" " } 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; + printf \"%$align$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; + printf \"%$align$width.${kB_precision}f%s%$width.${kB_precision}f k$unit_suffix\", rx, sep, wx; } if ($threshold > 0 && (rx >= $threshold || wx >= $threshold)) { printf \"\"; diff --git a/disk/disk b/disk/disk index c34240d7..9d64cc1e 100755 --- a/disk/disk +++ b/disk/disk @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Copyright (C) 2014 Julien Bonjean # This program is free software: you can redistribute it and/or modify diff --git a/docker/docker b/docker/docker index 5819cf9a..78e2ff6a 100755 --- a/docker/docker +++ b/docker/docker @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Number of docker containers running count=$(docker ps -q | wc -l | sed -r 's/^0$//g') diff --git a/essid/essid b/essid/essid index 2c3e421c..a23b3d22 100755 --- a/essid/essid +++ b/essid/essid @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright (C) 2018 borgified # Copyright (C) 2014 Alexander Keller diff --git a/eyedropper/LICENSE.md b/eyedropper/LICENSE.md new file mode 100644 index 00000000..f5a01711 --- /dev/null +++ b/eyedropper/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/eyedropper/README.md b/eyedropper/README.md new file mode 100644 index 00000000..f7198739 --- /dev/null +++ b/eyedropper/README.md @@ -0,0 +1,64 @@ +# Eyedropper + +Simple and convenient tool to identify the hex value of any color on the screen. Simply click on the icon: + +![](eyedropper_startup.png) + +Your mouse will become a crosshair. Click on any color you desire and both the color and the hex value will be displayed. + +![](eyedropper_example1.png) +![](eyedropper_example2.png) +![](eyedropper_example3.png) + +Should you select the color of your bar, you will not be able to see the icon (as the icon and the bar are the same color), but you will still be able to read the hex value +![](eyedropper_same_color.png) + +### Dependencies + +1. Ensure **grabc** is installed. For debian: + +``` +$ sudo apt-get install grabc +``` + +For more information, visit [muquit/grabc](https://github.com/muquit/grabc) + +2. [fontawesome](https://github.com/FortAwesome/Font-Awesome) + +### Optional Dependencies + +1. xclip - for copying the value to clipboard in i3 + +2. slurp, grim, imagemagick - for picking the color in SwayWM + +3. wl-clipboard - for copying the value to clipboard in SwayWM + +# Installation + +1. Copy script to your directory of choice +2. Give it execution permission (`chmod +x eyedropper`) +3. Add the following blocklet to your i3blocks.conf: + +### Configuring i3blocks + +```ini +[eyedropper] +command=$SCRIPT_DIR/eyedropper +full_text= +instance=#ffffff +markup=pango +#CLIPBOARD=true +#SWAY=true +``` + +- Change the "foreground" value in "full_text" to change the color of the initial eyedropper icon +- Change the "instance" value to change the color of the hex value displayed + +Two environment variable configuration options are supported: + +1. CLIPBOARD=true - Copy the color value to the clipboard in addition to updating the string +2. SWAY=true - Do color picking in a way that works when running in SwayWM (Wayland) + +### Sample Look + +![](eyedropper_sample.png) diff --git a/eyedropper/eyedropper b/eyedropper/eyedropper new file mode 100755 index 00000000..025c4a8a --- /dev/null +++ b/eyedropper/eyedropper @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright (C) 2021 Max Z. Tan + +# 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 . + +color=$BLOCK_INSTANCE + +if [ -z "${SWAY}" ]; then + # sleep to cater to grabc startup time + sleep 0.5 + value=$(grabc 2>/dev/null) + if [ "${CLIPBOARD}" ]; then + i3-msg -q exec "xclip -sel clip < <(echo -n \\$value)" + fi +else + value=$(grim -g "$(slurp -p -b '#00000000')" -t ppm - \ + | convert - -format '%[pixel:s]' info:- \ + | awk -F '[(,)]' '{printf("#%02x%02x%02x",$2,$3,$4)}') + if [ "${CLIPBOARD}" ]; then + swaymsg -q exec wl-copy "\\$value" + fi +fi +full_text="$value" + +echo $full_text diff --git a/eyedropper/eyedropper_example1.png b/eyedropper/eyedropper_example1.png new file mode 100644 index 00000000..f47df6aa Binary files /dev/null and b/eyedropper/eyedropper_example1.png differ diff --git a/eyedropper/eyedropper_example2.png b/eyedropper/eyedropper_example2.png new file mode 100644 index 00000000..548bf849 Binary files /dev/null and b/eyedropper/eyedropper_example2.png differ diff --git a/eyedropper/eyedropper_example3.png b/eyedropper/eyedropper_example3.png new file mode 100644 index 00000000..b20d73dc Binary files /dev/null and b/eyedropper/eyedropper_example3.png differ diff --git a/eyedropper/eyedropper_same_color.png b/eyedropper/eyedropper_same_color.png new file mode 100644 index 00000000..a1452a65 Binary files /dev/null and b/eyedropper/eyedropper_same_color.png differ diff --git a/eyedropper/eyedropper_sample.png b/eyedropper/eyedropper_sample.png new file mode 100644 index 00000000..a7426531 Binary files /dev/null and b/eyedropper/eyedropper_sample.png differ diff --git a/eyedropper/eyedropper_startup.png b/eyedropper/eyedropper_startup.png new file mode 100644 index 00000000..dbf9c3f5 Binary files /dev/null and b/eyedropper/eyedropper_startup.png differ diff --git a/eyedropper/i3block.conf b/eyedropper/i3block.conf new file mode 100644 index 00000000..8a2bf403 --- /dev/null +++ b/eyedropper/i3block.conf @@ -0,0 +1,7 @@ +[eyedropper] +command=$SCRIPT_DIR/eyedropper +full_text= +instance=#ffffff +markup=pango +#CLIPBOARD=true +#SWAY=true diff --git a/github/README.md b/github/README.md new file mode 100644 index 00000000..84f12c78 --- /dev/null +++ b/github/README.md @@ -0,0 +1,22 @@ +# Github + +Shows Github notifications and adds a shortcut to access your notifications. It uses [Github's CLI](https://github.com/cli/cli) for api interactions and for an API access. + +# Dependencies + +- [gh-cli](https://github.com/cli/cli) +- [Font Awesome](https://fontawesome.com) for the Github icon. + +# Usage + +Clicking the Github icon will open Github's notifications panel. + +# Config + +```ini +[github] +command=$SCRIPT_DIR/github/github +interval=60 +format=json +markup=pango +``` diff --git a/github/github b/github/github new file mode 100755 index 00000000..6e67b328 --- /dev/null +++ b/github/github @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +""" +A Github block for displaying notifications in i3 using i3blocks +""" + +__author__ = "Adin Hodovic " +__copyright__ = "Copyright (c) 2020 Adin Hodovic" +__license__ = "MIT" +__version__ = "1.0.0" + +import json +import os +import webbrowser + + +def get_notifications(): + notifications = len(json.loads(os.popen("gh api notifications").read())) + + if notifications > 0: + return { + "full_text": f" {notifications}" + } + return {"full_text": ""} + + +def clicked(): + """Returns True if the button was clicked""" + button = "BLOCK_BUTTON" in os.environ and os.environ["BLOCK_BUTTON"] + return bool(button) + + +if clicked(): + webbrowser.open("https://github.com/notifications") + +print(json.dumps(get_notifications())) diff --git a/github/i3blocks.conf b/github/i3blocks.conf new file mode 100644 index 00000000..9c2df6ee --- /dev/null +++ b/github/i3blocks.conf @@ -0,0 +1,5 @@ +[github] +command=$SCRIPT_DIR/github/github +interval=60 +format=json +markup=pango diff --git a/go/LICENCE.md b/go/LICENCE.md new file mode 100644 index 00000000..37091458 --- /dev/null +++ b/go/LICENCE.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/go/README.md b/go/README.md new file mode 100644 index 00000000..e5b3135b --- /dev/null +++ b/go/README.md @@ -0,0 +1,20 @@ +# go + +Show the currently installed Go version. + +![](kubernetes.png) + +# Dependencies + +*go* and *awk* must be installed and accessible under your *$PATH*. + +It's highly likely to also install a Nerd Fonts patched font to get the Gopher icon. + +# Config + +``` +[go] +command=$SCRIPT_DIR/go +interval=once +label= +``` diff --git a/go/go b/go/go new file mode 100755 index 00000000..6b7b953e --- /dev/null +++ b/go/go @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +go version 2>/dev/null | awk '{ gsub("go", ""); print $2 }' diff --git a/go/go.png b/go/go.png new file mode 100644 index 00000000..a57a21e1 Binary files /dev/null and b/go/go.png differ diff --git a/go/i3blocks.conf b/go/i3blocks.conf new file mode 100644 index 00000000..cd4aadd6 --- /dev/null +++ b/go/i3blocks.conf @@ -0,0 +1,4 @@ +[go] +command=$SCRIPT_DIR/go +interval=once +label= \ No newline at end of file diff --git a/gpu-load/README.md b/gpu-load/README.md index a9627ab9..7d486881 100644 --- a/gpu-load/README.md +++ b/gpu-load/README.md @@ -1,6 +1,6 @@ # gpu-load -Shows load of Nvidia GPUs. +Shows load of Nvidia or AMD GPUs. ![](gpu-load.png) @@ -8,14 +8,17 @@ 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 +3. Video buffer (NVIDIA only) +4. PCIe bus utilization (NVIDIA only) `short_text` only shows the GPU load. # Dependencies +Choose one depends on your GPU. + * `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. +* [`radeontop`](https://github.com/clbr/radeontop) # Config ``` @@ -24,6 +27,7 @@ command=$SCRIPT_DIR/gpu-load label=GPU interval=10 #min_width=GPU 100% 100% 100% 100% +#GPU_BRAND=NVIDIA // or AMD #T_WARN=70 #T_CRIT=90 ``` diff --git a/gpu-load/gpu-load b/gpu-load/gpu-load index 4d3ff0d3..49662191 100755 --- a/gpu-load/gpu-load +++ b/gpu-load/gpu-load @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#!/usr/bin/env 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 @@ -21,11 +21,14 @@ use Getopt::Long; # default values my $t_warn = $ENV{T_WARN} || 70; my $t_crit = $ENV{T_CRIT} || 90; +my $gpu_brand = $ENV{GPU_BRAND} || "NVIDIA"; my $gpu_usage = -1; my $gpu_mem = -1; my $gpu_video = -1; my $gpu_pcie = -1; +my $full_text = ""; + sub help { print "Usage: gpu-load [-w ] [-c ]\n"; print "-w : warning threshold to become amber\n"; @@ -38,22 +41,39 @@ GetOptions("help|h" => \&help, "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; +if ($gpu_brand eq "NVIDIA") { + 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); + $full_text = sprintf "%.0f%% %.0f%% %.0f%% %.0f%%\n", $gpu_usage, $gpu_mem, $gpu_video, $gpu_pcie; +} + +# For AMD, get from radeontop +elsif ($gpu_brand eq "AMD") { + open (AMD, 'radeontop -d - -l 1 |') or die; + while () { + if (/^.*[gpu] (\d+)\.\d+%.*.*[vram] (\d+)\.\d+%.*$/) { + $gpu_usage = $1; + $gpu_mem = $2; + last; + } } + close(AMD); + $full_text = sprintf "%.0f%% %.0f%%\n", $gpu_usage, $gpu_mem; } -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; +print $full_text; printf "%.0f%%\n", $gpu_usage; # Print color, if needed diff --git a/i3-focusedwindow/README.md b/i3-focusedwindow/README.md new file mode 100644 index 00000000..54339f78 --- /dev/null +++ b/i3-focusedwindow/README.md @@ -0,0 +1,28 @@ +# i3 Focused window + +Displays title of focused window in i3Wm + +![Demo](i3-focusedwindow.png) + +# Requirements + +Dependencies: `xprop`, `awk` + +# Command line arguments + +```bash +i3-focusedwindow [maximum length to display] +``` + +Blank for unlimited length, i.e. output line can occupy all available space. + +# Installation + +The recommended i3blocks config is + +```INI +[i3-focusedwindow] +label=[]= +command=$SCRIPT_DIR/i3-focusedwindow 20 +interval=persist +``` diff --git a/i3-focusedwindow/i3-focusedwindow b/i3-focusedwindow/i3-focusedwindow new file mode 100755 index 00000000..27304e32 --- /dev/null +++ b/i3-focusedwindow/i3-focusedwindow @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Author: Kn + +while : +do + ID=$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}') + if [[ $1 ]] + then + TITLE=$(xprop -id $ID -len $1 | awk '/_NET_WM_NAME/{$1=$2="";print}' | cut -d'"' -f2) + echo "$TITLE" + else + TITLE=$(xprop -id $ID | awk '/_NET_WM_NAME/{$1=$2="";print}' | cut -d'"' -f2) + echo "$TITLE" + fi +done diff --git a/i3-focusedwindow/i3-focusedwindow.png b/i3-focusedwindow/i3-focusedwindow.png new file mode 100644 index 00000000..ad1efd24 Binary files /dev/null and b/i3-focusedwindow/i3-focusedwindow.png differ diff --git a/iface/README.md b/iface/README.md index e60e7b9e..06e1e102 100644 --- a/iface/README.md +++ b/iface/README.md @@ -2,7 +2,7 @@ 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 +Specify ipv6, ipv4, or either by setting `ADDRESS_FAMILY` to `inet6`, `inet`, or `inet6?`. If an invalid interface is specified, nothing is printed. @@ -13,12 +13,4 @@ If an invalid interface is specified, nothing is printed. # Config -``` -[iface] -command=$SCRIPT_DIR/iface -#LABEL=wlan0: -#IFACE=wlan0 -#ADDRESS_FAMILY=inet6? -color=#00FF00 -interval=10 -``` +See `./i3blocks.conf` for an example configuration. \ No newline at end of file diff --git a/iface/i3blocks.conf b/iface/i3blocks.conf index 1202a852..d7e3b574 100644 --- a/iface/i3blocks.conf +++ b/iface/i3blocks.conf @@ -5,3 +5,5 @@ command=$SCRIPT_DIR/iface #ADDRESS_FAMILY=inet6? color=#00FF00 interval=10 +# set this to 1 to display the name of the connected WIFI interface instead of the IP address. +display_wifi_name=0 diff --git a/iface/iface b/iface/iface index 75baa947..8ee1061d 100755 --- a/iface/iface +++ b/iface/iface @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright (C) 2014 Julien Bonjean # Copyright (C) 2014 Alexander Keller @@ -43,16 +43,16 @@ for flag in "$1" "$2"; do AF=inet6 ;; -L) if [[ "$IF" = "" ]]; then - LABEL="iface " + LABEL="iface" else - LABEL="$IF: " + 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 "${LABEL} down" # full text + echo "${LABEL} down" # short text echo \#FF0000 # color exit fi @@ -64,7 +64,26 @@ case $BLOCK_BUTTON in 3) echo -n "$IPADDR" | xclip -q -se c ;; esac +if [[ "${display_wifi_name}" == "1" ]]; +then + # try to guess the wifi name + if command -v iw > /dev/null && iw $IF info > /dev/null 2>&1; + then + WIFI_NAME=$(iw $IF info | grep -Po '(?<=ssid ).*' | tr -d " \t\n\r") + + if [[ $BLOCK_BUTTON -eq 1 ]]; + then + message="$LABEL $WIFI_NAME ($IPADDR)" + else + message="$LABEL $WIFI_NAME" + fi + else + message="$LABEL $IPADDR" + fi +else + message="$LABEL $IPADDR" +fi + #------------------------------------------------------------------------ -echo "$LABEL$IPADDR" # full text -echo "$LABEL$IPADDR" # short text +echo "$message" diff --git a/kbdd_layout/kbdd_layout b/kbdd_layout/kbdd_layout index 96fd4b61..af9e9532 100755 --- a/kbdd_layout/kbdd_layout +++ b/kbdd_layout/kbdd_layout @@ -1,23 +1,31 @@ -#!/usr/bin/env bash +#!/bin/bash # -# kbdd_layout is a script that parse layout with kbdd in real time -# Copyright (C) 2016 Anton Karmanov +# kbdd_layout is a script that parse layout with kbdd in real time +# Copyright (C) 2016,2019 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 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. +# 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 . +# 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 +# Matches first 3 letters of layout name. +MATCH='\w{3}' + +# Matches short layout name. +#MATCH='\w*' + +# Matches full layout name. +#MATCH='\w*(\s\(.*\))?' + +# Restart kbdd to apply layout changes on block reload. killall kbdd 2>/dev/null kbdd >/dev/null || exit 1 @@ -26,16 +34,17 @@ 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 +# 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 ) +dbus-send --print-reply=literal --dest=ru.gentoo.KbddService \ + /ru/gentoo/KbddService ru.gentoo.kbdd.getLayoutName uint32:"$N" |\ + grep -Po "${MATCH}" | head -n1 -# Parse dbus output +# Parse dbus output. dbus-monitor "interface='ru.gentoo.kbdd',member='layoutNameChanged'" |\ - sed -un '0~2p' | sed -un 's:.*string "\(.*\)".*:\1:p' | sed -u '/:/d' + grep -Po --line-buffered "(?<=string \")${MATCH}" \ No newline at end of file diff --git a/key_light/README.md b/key_light/README.md new file mode 100644 index 00000000..7712ba2a --- /dev/null +++ b/key_light/README.md @@ -0,0 +1,19 @@ +# key_light + +Control the keyboard backlight. When clicked, the keyboard backlight is +increased until the maximum level is reached after which the backlight is +turned off. + +![](key_light.png) + +# Dependencies + +* [upower](https://upower.freedesktop.org/) + +# Config + +``` +[key_light] +full_text=⌨ +command=$SCRIPT_DIR/key_light +``` diff --git a/key_light/i3blocks.conf b/key_light/i3blocks.conf new file mode 100644 index 00000000..d3a5cb10 --- /dev/null +++ b/key_light/i3blocks.conf @@ -0,0 +1,3 @@ +[key_light] +full_text=⌨ +command=$SCRIPT_DIR/key_light/key_light diff --git a/key_light/key_light b/key_light/key_light new file mode 100755 index 00000000..3deee0c5 --- /dev/null +++ b/key_light/key_light @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright 2019 Matej Čamaj +# +# 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 . + +# See https://upower.freedesktop.org/docs/KbdBacklight.html +function get_brightness { + dbus-send --system --type=method_call --print-reply\ + --dest="org.freedesktop.UPower" \ + "/org/freedesktop/UPower/KbdBacklight" \ + "org.freedesktop.UPower.KbdBacklight.$1" \ + | awk 'FNR==2{print $2}' +} + +brightness=$(get_brightness "GetBrightness") +max_brightness=$(get_brightness "GetMaxBrightness") + +if [ "$brightness" -eq "$max_brightness" ]; then + new_brightness=0 +else + new_brightness=$((brightness + 1)) +fi + +dbus-send --system --type=method_call \ + --dest="org.freedesktop.UPower" \ + "/org/freedesktop/UPower/KbdBacklight" \ + "org.freedesktop.UPower.KbdBacklight.SetBrightness" int32:$new_brightness diff --git a/key_light/key_light.png b/key_light/key_light.png new file mode 100644 index 00000000..97e68dee Binary files /dev/null and b/key_light/key_light.png differ diff --git a/keyindicator/LICENSE.md b/keyindicator/LICENSE.md new file mode 100644 index 00000000..660ee4ed --- /dev/null +++ b/keyindicator/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/keyindicator/README.md b/keyindicator/README.md index d71ad570..bcca8c73 100644 --- a/keyindicator/README.md +++ b/keyindicator/README.md @@ -2,9 +2,7 @@ Show the status of capslock or numlock. -![](keyindicator-active.png) - -![](keyindicator-inactive.png) +![](keyindicator-active-vs-inactive.png) # Installation @@ -25,6 +23,8 @@ KEY=CAPS markup=pango interval=once signal=11 +#TEXT_ON=CapsLockOn +#TEXT_OFF=CapsLockOff #COLOR_ON=#00FF00 #COLOR_OFF=#222222 #BG_COLOR_ON= @@ -36,6 +36,8 @@ KEY=NUM markup=pango interval=once signal=11 +#TEXT_ON=NumLockOn +#TEXT_OFF=NumLockOff #COLOR_ON=#00FF00 HIDE_WHEN_OFF=1 ``` diff --git a/keyindicator/keyindicator b/keyindicator/keyindicator index 50c3a3ff..d7dab672 100755 --- a/keyindicator/keyindicator +++ b/keyindicator/keyindicator @@ -23,6 +23,8 @@ use File::Basename; # Default values my $indicator = $ENV{BLOCK_INSTANCE} || $ENV{KEY} || "CAPS"; +my $text_on = $ENV{TEXT_ON} || $indicator; +my $text_off = $ENV{TEXT_OFF} || $indicator; my $color_on = $ENV{COLOR_ON} || "#00FF00"; my $color_off = $ENV{COLOR_OFF} || "#222222"; my $bg_color_on = $ENV{BG_COLOR_ON}; @@ -77,6 +79,7 @@ if ($hide and !$indicator_status) { } # Output +$indicator = $indicator_status ? $text_on : $text_off; my $fg_color = $indicator_status ? $color_on : $color_off; my $bg_color = $indicator_status ? $bg_color_on : $bg_color_off; diff --git a/keyindicator/keyindicator-active-vs-inactive.png b/keyindicator/keyindicator-active-vs-inactive.png new file mode 100644 index 00000000..f45c905a Binary files /dev/null and b/keyindicator/keyindicator-active-vs-inactive.png differ diff --git a/keyindicator/keyindicator-active.png b/keyindicator/keyindicator-active.png deleted file mode 100644 index 2023bbf4..00000000 Binary files a/keyindicator/keyindicator-active.png and /dev/null differ diff --git a/keyindicator/keyindicator-inactive.png b/keyindicator/keyindicator-inactive.png deleted file mode 100644 index 5076ca01..00000000 Binary files a/keyindicator/keyindicator-inactive.png and /dev/null differ diff --git a/kubernetes/kubernetes b/kubernetes/kubernetes index f04efff7..0169eef0 100755 --- a/kubernetes/kubernetes +++ b/kubernetes/kubernetes @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash KCONTEXT=$(kubectl config current-context 2>/dev/null) if [[ $?=="0" ]]; then CC=$(kubectl config view -ojsonpath='{..current-context}') diff --git a/load_average/load_average b/load_average/load_average index 37a5c718..9ca6803d 100755 --- a/load_average/load_average +++ b/load_average/load_average @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Copyright (C) 2014 Julien Bonjean # This program is free software: you can redistribute it and/or modify diff --git a/memory/memory b/memory/memory index 90eb2c65..38e0cb1f 100755 --- a/memory/memory +++ b/memory/memory @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Copyright (C) 2014 Julien Bonjean # This program is free software: you can redistribute it and/or modify diff --git a/memory2/.gitignore b/memory2/.gitignore new file mode 100644 index 00000000..44068c11 --- /dev/null +++ b/memory2/.gitignore @@ -0,0 +1 @@ +memory2 \ No newline at end of file diff --git a/memory2/Makefile b/memory2/Makefile new file mode 100644 index 00000000..51170a14 --- /dev/null +++ b/memory2/Makefile @@ -0,0 +1,6 @@ +P=memory2 +OBJECTS= +CFLAGS=-g -Wall -Werror -O2 -std=c11 +LDLIBS= + +$(P): $(OBJECTS) diff --git a/memory2/README.md b/memory2/README.md new file mode 100644 index 00000000..5c114fc7 --- /dev/null +++ b/memory2/README.md @@ -0,0 +1,42 @@ +# memory2 +Display memory usage as a bar rendered with utf8 characters. + +![](memory2.png) +![](memory2_2.png) + +Features: +customizable warning and critical color levels +customizable size +customizable characters + +## Build + +``` +make +``` + +### Config +```ini +[memory2] +interval=persist +markup=pango +bar_chars=_▁▂▃▄▅▆▇█ +#bar_size=10 +#critical=80 +#warning=50 +#color_critical=#FF7373 +#color_warning=#FFA500 +``` + +E.g. +```ini +[memory2] +label= +interval=persist +markup=pango +bar_chars=_▏▎▍▌▋▊▉██ +bar_size=20 +critical=50 +warning=20 +color_critical=#d9534f +``` \ No newline at end of file diff --git a/memory2/memory2.c b/memory2/memory2.c new file mode 100644 index 00000000..d3dd86f2 --- /dev/null +++ b/memory2/memory2.c @@ -0,0 +1,168 @@ +#define _DEFAULT_SOURCE +#include +#include +#include +#include +#include +#include +#include + +#define RED "#FF7373" +#define ORANGE "#FFA500" + + +typedef unsigned long ulong; +typedef unsigned int uint; +typedef struct sysinfo sysinfo_t; + + +typedef struct { + char bytes[4]; + int size; +} utf8_char; + + +#define BYTE_ONE 0x80 // 10000000 +#define BYTE_TWO 0xC0 // 11000000 +#define BYTE_THREE 0xE0 // 11100000 +#define BYTE_FOUR 0xF0 // 11110000 +#define BYTE_FIVE 0xF8 // 11111000 + + +uint utf8_char_count(const char* str) +{ + uint count = 0; + while(*str) { + count += (*str & BYTE_TWO) != BYTE_ONE; + str++; + } + return count; +} + + +void load_bar_chars(utf8_char* bar_chars, uint count, char* characters) { + char* c = characters; + for (uint i = 0; i < count; i++) { + int size = 0; + utf8_char* b = bar_chars + i; + if ( !c[0] ) { + // error + printf("FAILED TO LOAD CHARS CORRECT"); + } else if (!(c[0] & BYTE_ONE)) { + // character is one byte + size = 1; + } else if ( (c[0] & BYTE_THREE) == BYTE_TWO ) { + size = 2; + } else if ( (c[0] & BYTE_FOUR) == BYTE_THREE) { + size = 3; + } else if ( (c[0] & BYTE_FIVE) == BYTE_FOUR) { + size = 4; + } + + for (uint j = 0; j < size; j++) + b->bytes[j] = c[j]; + + b->size = size; + + c += size; + } +} + +int clamp(int value, int min, int max) { + return value < min ? min : (value > max ? max : value); +} + + +int main(int argc, char *argv[]) +{ + // load environment variables + char *characters = ""; + uint bar_size = 10; + char *envvar = NULL; + int warning = 50; + int critical = 80; + char* color_warning = ORANGE; + char* color_critical = RED; + + envvar = getenv("bar_chars"); + if (envvar) + characters = envvar; + envvar = getenv("bar_size"); + if (envvar) + bar_size = atoi(envvar); + envvar = getenv("critical"); + if (envvar) + critical = atoi(envvar); + envvar = getenv("warning"); + if (envvar) + warning = atoi(envvar); + envvar = getenv("color_warning"); + if (envvar) + color_warning = envvar; + envvar = getenv("color_critical"); + if (envvar) + color_critical = envvar; + + uint count = utf8_char_count(characters); + utf8_char* bar_chars = (utf8_char*)malloc(count * sizeof(utf8_char)); + + load_bar_chars(bar_chars, count, characters); + + // allocate the maximun size possible + int buffer_size = (bar_size * 4) + 1; + char* buffer = (char*)malloc(buffer_size); + + + uint t = 1; + while (1) { + + + sysinfo_t info; + sysinfo(&info); + + long total = info.totalram; + long free = info.freeram; + long usage = total - free; + + float percent = 100 * ((float)usage / total); + float bar_percent = percent; + + memset(buffer, 0, buffer_size); + + //printf("%ld/%ld %f ", usage, total, percent); + char* write_point = buffer; + + float section_size = 100.0 / bar_size; + for (uint i = 0; i < bar_size; i++) { + int section_val = clamp((int)bar_percent, 0, count-1); + utf8_char u_char = bar_chars[section_val]; + + for (uint j = 0; j < u_char.size; j++) + write_point[j] = u_char.bytes[j]; + + bar_percent -= section_size; + write_point += u_char.size; + } + + if (critical != 0 && percent > critical) { + printf("", color_critical); + } else if (warning != 0 && percent > warning) { + printf("", color_warning); + } else { + printf(""); + } + + const float byte_to_gb = 1024 * 1024 * 1024; + + float usage_gb = usage / byte_to_gb; + float total_gb = total / byte_to_gb; + + printf("%s %4.1fG/%4.1fG (%i%%)\n", buffer, usage_gb, total_gb, (int)percent); + fflush(stdout); + + sleep(t); + } + free(buffer); + free(bar_chars); + return EXIT_SUCCESS; +} diff --git a/memory2/memory2.png b/memory2/memory2.png new file mode 100644 index 00000000..7469f1d0 Binary files /dev/null and b/memory2/memory2.png differ diff --git a/memory2/memory2_2.png b/memory2/memory2_2.png new file mode 100644 index 00000000..63427a0a Binary files /dev/null and b/memory2/memory2_2.png differ diff --git a/miccontrol/README.md b/miccontrol/README.md new file mode 100644 index 00000000..901d706b --- /dev/null +++ b/miccontrol/README.md @@ -0,0 +1,30 @@ +# miccontrol + +Shows the status of you microphone. Left and right click toggles mute. + +![](screenshot1.png) ![](screenshot2.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. + +``` +# toggle mute +bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute "alsa_input.pci-0000_00_1f.3.analog-stereo" toggle && pkill -RTMIN+10 i3blocks +``` +where the `alsa_input.pci-0000_00_1f.3.analog-stereo` after `set-source-mute` can be changed to another source name +and `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 + +``` +[miccontrol] +command=$SCRIPT_DIR/miccontrol +#label=MIC +SOURCE=alsa_input.pci-0000_00_1f.3.analog-stereo +interval=10 +signal=10 +``` + diff --git a/miccontrol/i3blocks.conf b/miccontrol/i3blocks.conf new file mode 100644 index 00000000..3266b360 --- /dev/null +++ b/miccontrol/i3blocks.conf @@ -0,0 +1,6 @@ +[miccontrol] +command=$SCRIPT_DIR/miccontrol +#label=MIC +SOURCE=alsa_input.pci-0000_00_1f.3.analog-stereo +interval=10 +signal=10 diff --git a/miccontrol/miccontrol b/miccontrol/miccontrol new file mode 100755 index 00000000..27b844f6 --- /dev/null +++ b/miccontrol/miccontrol @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Copyright © 2020 Filip Paskali +# +# 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 . + +case $BLOCK_BUTTON in + 1|3) pactl set-source-mute $SOURCE toggle ;; +esac + +case $(pacmd list-sources | grep -A 11 "$SOURCE" | awk '/muted/ {print $2; exit}') in + yes) + echo "" + ;; + no) + echo "" + ;; +esac diff --git a/miccontrol/screenshot1.png b/miccontrol/screenshot1.png new file mode 100644 index 00000000..5d39f334 Binary files /dev/null and b/miccontrol/screenshot1.png differ diff --git a/miccontrol/screenshot2.png b/miccontrol/screenshot2.png new file mode 100644 index 00000000..6d355e0f Binary files /dev/null and b/miccontrol/screenshot2.png differ diff --git a/nm-vpn/README.md b/nm-vpn/README.md index f1f9dca7..2c48be8d 100644 --- a/nm-vpn/README.md +++ b/nm-vpn/README.md @@ -15,23 +15,32 @@ Parses output from `nmcli` to show the current connected VPN name/status # 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. +`nm-vpn` gets active connection info from `nmcli`, looks for interface type `tun`, `tap`, `vpn`. A VPN connection is treated as established only when `tun`|`tap` is present, when it's not and a `vpn` connection is listed as active it is treated as initializing. + +# Tunables + +`init_color` - color used for marking a connection in initializing state, default is '#FFFF00' + +`on_color` - color used for marking a connection in established state, default is '#00FF00' ## Output -When `tun0` is active, `nm-vpn` will print in the following form: - - Full: `VPN: "Name"` +When `tun`|`tap` is active, `nm-vpn` will print in the following form: + - Full: `VPN Name` - Short: `ON` + - Color will be set to `on_color` value -In addition, each form will be coloured green (“\#00FF00”). +When `tun`|`tap` in not active, `nm-vpn` will print in the following form: + - Full: `VPN Name` + - Short: `INIT` + - Color will be set to `init_color` value # Config ``` ini [nm-vpn] -label=VPN: +#init_color=#FFFF00 +#on_color=#00FF00 +label=VPN: interval=5 ``` diff --git a/nm-vpn/i3blocks.conf b/nm-vpn/i3blocks.conf index 832fe81d..8f4ee130 100644 --- a/nm-vpn/i3blocks.conf +++ b/nm-vpn/i3blocks.conf @@ -1,5 +1,7 @@ [nm-vpn] -label=VPN: +#init_color=#FFFF00 +#on_color=#00FF00 +label=VPN: interval=5 # vim: syntax=dosini diff --git a/nm-vpn/nm-vpn b/nm-vpn/nm-vpn index 7c98fd54..9d2f52d3 100755 --- a/nm-vpn/nm-vpn +++ b/nm-vpn/nm-vpn @@ -1,4 +1,20 @@ -#!/bin/sh +#!/usr/bin/env sh +init_color=${init_color:-#FFFF00} +on_color=${on_color:-#00FF00} +export init_color on_color 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")}' +BEGIN { + init_color=ENVIRON["init_color"] + on_color=ENVIRON["on_color"] +} +$3=="vpn" { + name=$1 + status="INIT" + color=init_color +} +$3=="tun" || ($4~/^tap/ || $3~/^tap/) { + if(!name) name=$1 + status="ON" + color=on_color +} +END {if(status) printf("%s\n%s\n%s\n", name, status, color)}' diff --git a/openvpn-systemd/README.md b/openvpn-systemd/README.md new file mode 100644 index 00000000..01f70e96 --- /dev/null +++ b/openvpn-systemd/README.md @@ -0,0 +1,14 @@ +# openvpn-systemd + +Show connection status of VPNs managed by systemd. + +![](openvpn-systemd.png) + +# Config + +```ini +[openvpn-systemd] +command=$SCRIPT_DIR/openvpn-systemd +interval=20 +label=VPN +``` diff --git a/openvpn-systemd/openvpn-systemd b/openvpn-systemd/openvpn-systemd new file mode 100755 index 00000000..b01c3a4a --- /dev/null +++ b/openvpn-systemd/openvpn-systemd @@ -0,0 +1,23 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use utf8; + +use JSON::Parse 'parse_json'; + +my $units = parse_json(`systemctl list-units --output=json --state=active 'openvpn-client@*'`); + +if (@$units) { + my @names = sort map { + $_->{unit} =~ /^openvpn-client@(.*)\.service$/; + $1; + } @$units; + print join(' ', @names) . "\n"; + print "up\n"; + print "#00FF00\n"; +} else { + print "down\n"; + print "down\n"; + print "#FF0000\n"; +} diff --git a/openvpn-systemd/openvpn-systemd.png b/openvpn-systemd/openvpn-systemd.png new file mode 100644 index 00000000..3d776750 Binary files /dev/null and b/openvpn-systemd/openvpn-systemd.png differ diff --git a/optimus-manager/README.md b/optimus-manager/README.md new file mode 100644 index 00000000..e7b65ddf --- /dev/null +++ b/optimus-manager/README.md @@ -0,0 +1,16 @@ +# optimus-manager + +Show current GPU using optimus-manager. Changes GPU on block click. + +![optimus-manager-nvidia](./optimus-manager-nvidia.png) +![optimus-manager-intel](./optimus-manager-intel.png) + +# Dependencies +- [optimus-manager](https://github.com/Askannz/optimus-manager) + +# Config +``` +[optimus-manager] +command=$SCRIPT_DIR/optimus-manager +interval=30 +``` diff --git a/optimus-manager/i3blocks.conf b/optimus-manager/i3blocks.conf new file mode 100644 index 00000000..fca02b4e --- /dev/null +++ b/optimus-manager/i3blocks.conf @@ -0,0 +1,3 @@ +[optimus-manager] +command=$SCRIPT_DIR/optimus-manager +interval=30 diff --git a/optimus-manager/optimus-manager b/optimus-manager/optimus-manager new file mode 100644 index 00000000..ad7eb318 --- /dev/null +++ b/optimus-manager/optimus-manager @@ -0,0 +1,23 @@ +#!/usr/bin/env sh +# Copyright (C) 2021 Marcos Felipe Eipper + +# 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 . + +CURRENT_GPU=$(optimus-manager --status | awk '/Current/ {print $5}') + +case $BLOCK_BUTTON in + 1) optimus-manager --switch $(if [ "${CURRENT_GPU}" = "intel" ]; then echo "nvidia"; else echo "intel"; fi) --no-confirm ;; +esac + +echo "${CURRENT_GPU}" diff --git a/optimus-manager/optimus-manager-intel.png b/optimus-manager/optimus-manager-intel.png new file mode 100644 index 00000000..77590245 Binary files /dev/null and b/optimus-manager/optimus-manager-intel.png differ diff --git a/optimus-manager/optimus-manager-nvidia.png b/optimus-manager/optimus-manager-nvidia.png new file mode 100644 index 00000000..ccc4e34f Binary files /dev/null and b/optimus-manager/optimus-manager-nvidia.png differ diff --git a/purpleair/LICENSE b/purpleair/LICENSE new file mode 100644 index 00000000..d159169d --- /dev/null +++ b/purpleair/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/purpleair/README.md b/purpleair/README.md new file mode 100644 index 00000000..3767814a --- /dev/null +++ b/purpleair/README.md @@ -0,0 +1,76 @@ +# purpleair + +Get air quality readings from [PurpleAir](http://purpleair.com) sensors. + +![](purpleair.png) + +# Requirements + +Dependencies: perl, curl, jq + +# Configuration + +A purpleair config block looks like this: + +```INI +[purpleair] +label= +command=$SCRIPT_DIR/purpleair +interval=60 +SENSOR_ID=78305 +#TYPE=US_AQI +#COLORS=#85df56,#fbcf4b,#f28c33,#dd4d3c,#cf79e0,#9b2f6a +#NO_COLOR=true +``` + +## Finding a sensor ID + +If you do not own a PurpleAir sensor, there may be one near you that you can query. Here's how to find a sensor ID: + +1. Navigate to http://purpleair.com/map and find a reading near you. +1. Click on the reading to bring up a details card. (Note, sensors with a block border are indoors. You'll likely want a plain circle). +1. At the bottom of the card, hover over "Get This Widget", and click the "JSON" link. +1. The sensor ID is the value of the URL's "show" query parameter. + +If you own a PurpleAir sensor, use its ID. If your sensor is configured to be private, see the [PurpleAir FAQ](https://www2.purpleair.com/community/faq#hc-access-the-json) for extra access requirements. If your sensor is public and you do not know its ID, see the instructions above to find it. + +## Configuration Parameters + +There is one required parameter, along with some optional ones: + +Parameter | Description +--------- | ----------- +SENSOR_ID | Required: The PurpleAir sensor to query +TYPE | Optional: The air quality computation to perform. Default: US_AQI +COLORS | Optional: Comma-separated list of color hex values to use in place of the default colors +NO_COLOR | Optional: Any non-empty value causes color to be suppressed + +### TYPE + +The valid values for `TYPE` are: + +Type | Description +------- | ----------- +US_AQI | [United States Air Quality Index](https://www.airnow.gov/aqi/aqi-basics/) +EU_AQI | [European Air Quality Index](https://airindex.eea.europa.eu/) +CA_AQHI | [Canada Air Quality Health Index](https://www.canada.ca/en/environment-climate-change/services/air-quality-health-index/about.html) +IMECA | [Índice MEtropolitano de la Calidad del Aire](https://www.gob.mx/comisionambiental/es/articulos/imeca-indice-metropolitano-de-la-calidad-del-aire) +IAS | [Índice de Aire y Salud](http://www.aire.cdmx.gob.mx/default.php?opc=%27ZaBhnmI=&dc=%27Zw==) + +### COLORS + +The `COLORS` parameter should be specified without spaces or quotes. + +Good: `COLORS=#ffffff,#aaaaaa,#888888` + +Bad: `COLORS="#ffffff,#aaaaaa,#888888"` + +Bad: `COLORS=#ffffff, #aaaaaa, #888888` + +If fewer colors are specified than the `TYPE` uses by default, a warning will be printed to `stderr`. Also, any color index higher than the maximum index given will be reduced to the maximum index. + +### NO_COLOR + +The `NO_COLOR` parameter suppresses colors, so the output will use the default output color of the bar. + +Any non-empty value will trigger its effect, but by convention it should be specified `NO_COLOR=true`. diff --git a/purpleair/i3blocks.conf b/purpleair/i3blocks.conf new file mode 100644 index 00000000..fe17dc19 --- /dev/null +++ b/purpleair/i3blocks.conf @@ -0,0 +1,7 @@ +[purpleair] +label= +command=$SCRIPT_DIR/purpleair +interval=60 +SENSOR_ID=78305 +TYPE=US_AQI +COLORS=#85df56,#fbcf4b,#f28c33,#dd4d3c,#cf79e0,#9b2f6a diff --git a/purpleair/purpleair b/purpleair/purpleair new file mode 100755 index 00000000..6f6523d3 --- /dev/null +++ b/purpleair/purpleair @@ -0,0 +1,249 @@ +#!/bin/perl +# For temperature: subtract 8 from the F value for the actual temperature + +# Get PurpleAir sensor ID +if ($ENV{'SENSOR_ID'} == "") { + print STDERR "Missing required environment variable 'SENSOR_ID'.\n"; + exit 1; +} +$sensor_id = $ENV{'SENSOR_ID'}; + +# Get measurement type. Default: US_AQI +@valid_types = ("US_AQI", "EU_AQI", "CA_AQHI", "IMECA", "IAS"); +$type = 'US_AQI'; +if (grep(/^$ENV{'TYPE'}$/, @valid_types)) { + $type = $ENV{'TYPE'}; +} elsif ($ENV{'TYPE'}) { + print STDERR "Unrecognized TYPE: $ENV{'TYPE'}. Valid values are: [@valid_types]"; + exit 1; +} + +# Read pm2.5 10-minute average from the PurpleAir sensor +$pm2_5 = `curl "http://purpleair.com/json?show=$sensor_id" 2>/dev/null \\ + | jq -r '.results | map(select(has("Stats")) | .Stats | fromjson | .v1) | add / length'`; + +################### +# IMPLEMENTATIONS # +################### + +sub UsAqi { + # See https://forum.airnowtech.org/t/the-aqi-equation/169 + # + # PM2.5 | ConcLo | ConcHi | AQILo | AQIHi + # Good | 0.0 | 12.0 | 0 | 50 + # Moderate | 12.1 | 35.4 | 51 | 100 + # Unhealthy Sensitive | 35.5 | 55.4 | 101 | 150 + # Unhealthy | 55.5 | 150.4 | 151 | 200 + # Very Unhealthy | 150.5 | 250.4 | 201 | 300 + # Hazardous | 250.5 | 500.4 | 301 | 500 + # + # |------------Multiplier-----------| Threshold Addition + # (AQIHi - AQILo) / (ConcHi - ConcLo) * (ConcNow - ConcLo) + AQILo + + @colors = ("#00e400", "#ffff00", "#ff7e00", "#ff0000", "#8f3f97", "#7e0023"); + $pm2_5 = $_[0]; + + # Table of values: Threshold, Multiplier, Addition + @t = ( + [0.0, 4.1667, 0.0], + [12.1, 2.1030, 51], + [35.5, 2.4623, 101], + [55.5, 0.5163, 151], + [150.5, 0.9910, 201], + [250.5, 0.7963, 301] + ); + + # Find relevant row for computation based on pm2.5 threshold + for ($i = 5; $i >= 0; $i--) { + if ($pm2_5 >= $t[$i][0]) { + $r = $i; + last; + } + } + + # Compute AQI from raw pm2.5 concentration + $aqi = $t[$r][1] * ($pm2_5 - $t[$r][0]) + $t[$r][2]; + + return ( + 'val' => sprintf("%.0f", $aqi), + 'colors' => [@colors], + 'color_idx' => $r + ); +} + +sub EuAqi { + # See https://airindex.eea.europa.eu/Map/AQI/Viewer/ + # European Air Quality Index uses the pm2.5 concentration directly. + + @colors = ("#50f0e6", "#50ccaa", "#f0e641", "#ff5050", "#960032", "#7d2181"); + $pm2_5 = $_[0]; + + # Thresholds for color indices + @t = (0.0, 10.0, 20.0, 25.0, 50.0, 75.0); + + # Find relevant row for computation based on pm2.5 threshold + for ($i = 5; $i >= 0; $i--) { + if ($pm2_5 >= $t[$i]) { + $r = $i; + last; + } + } + + return ( + 'val' => sprintf("%.0f", $pm2_5), + 'colors' => [@colors], + 'color_idx' => $r + ); +} + +sub CaAqhi { + # See https://en.wikipedia.org/wiki/Air_Quality_Health_Index_(Canada)#Calculation + # Note: AQHI should also incorporate O3 and NO2, but PurpleAir only has PM2.5 + # The pm2.5 calculation is used alone and multiplied by 3. + # 1-3: Low + # 4-6: Moderate + # 7-10: High + # 11+: Very High + + @colors = ( + "#00ccff", "#0099cc", "#006699", + "#ffff00", "#ffcc00", "#ff9933", + "#ff6666", "#ff0000", "#cc0000", + "#990000", "#660000"); + $pm2_5 = $_[0]; + + $aqhi = 3 * 1000 / 10.4 * ((exp(0.000487 * $pm2_5) - 1)); + + return ( + 'val' => sprintf("%.0f", $aqhi >= 1 ? $aqhi : 1), + 'colors' => [@colors], + 'color_idx' => $r + ); +} + +sub Imeca { + # See http://rama.edomex.gob.mx/imeca + # + # PM2.5 | Threshold | Multiplier | Addition + # Buena | 0.0 | 4.17 | 0 + # Regular | 12.1 | 1.49 | 51 + # Mala | 45.1 | 0.94 | 101 + # Muy Mala | 97.5 | 0.93 | 151 + # Extremadamente Mala | 150.5 | 0.99 | 201 + # Extremadamente Mala | 250.5 | 0.99 | 301 + # Extremadamente Mala | 350.5 | 0.66 | 401 + # + # Multiplier * (pm2.5 - Threshold) + Addition + + @colors = ("#00e400", "#ffff00", "#ff7e00", "#ff0000", "#99004c", "#99004c", "#99004c"); + $pm2_5 = $_[0]; + + # Table of values: Threshold, Multiplier, Addition + @t = ( + [0.0, 4.17, 0.0], + [12.1, 1.49, 51.0], + [45.1, 0.94, 101.0], + [97.5, 0.93, 151.0], + [150.5, 0.99, 201.0], + [250.5, 0.99, 301.0], + [350.5, 0.66, 401.0] + ); + + # Find relevant row for computation based on pm2.5 threshold + for ($i = 6; $i >= 0; $i--) { + if ($pm2_5 >= $t[$i][0]) { + $r = $i; + last; + } + } + + # Compute AQI from raw pm2.5 concentration + $aqi = $t[$r][1] * ($pm2_5 - $t[$r][0]) + $t[$r][2]; + + return ( + 'val' => sprintf("%.0f", $aqi), + 'colors' => [@colors], + 'color_idx' => $r + ); +} + +sub Ias { + # See https://www.dof.gob.mx/nota_detalle_popup.php?codigo=5576807 + # Índice de aire y salud uses the pm2.5 concentration directly. + + @colors = ("#00e400", "#ffff00", "#ff7e00", "#ff0000", "#99004c"); + $pm2_5 = $_[0]; + + # Thresholds for color indices + @t = (0.0, 26.0, 46.0, 80.0, 148.0); + + # Find relevant row for computation based on pm2.5 threshold + for ($i = 4; $i >= 0; $i--) { + if ($pm2_5 >= $t[$i]) { + $r = $i; + last; + } + } + + return ( + 'val' => sprintf("%.0f", $pm2_5), + 'colors' => [@colors], + 'color_idx' => $r + ); +} + +################## +# OUTPUT RESULTS # +################## + +# Compute requested value +# Expected return value is a hash of the form: +# ( +# 'val' => , +# 'colors' => [], +# 'color_idx' => <0-based index of color array>, +# ) +if ($type eq "US_AQI") { + %result = UsAqi($pm2_5); +} elsif ($type eq "EU_AQI") { + %result = EuAqi($pm2_5); +} elsif ($type eq "CA_AQHI") { + %result = CaAqhi($pm2_5); +} elsif ($type eq "IMECA") { + %result = Imeca($pm2_5); +} elsif ($type eq "IAS") { + %result = Ias($pm2_5); +} else { + # It should not be possible to reach here. + %result = ( + 'val' => 'ERR', + 'colors' => ("#ff0000"), + 'color_idx' => 0, + 'num_colors' => 1 + ); +} + +# Get color overrides, if any. +if ($ENV{'COLORS'}) { + @colors = split(',', $ENV{'COLORS'}); + if (scalar(@colors) < scalar(@{ $result{'colors'} })) { + print STDERR "Warning: number of color overrides is fewer than the number". + " of buckets in type $type\n"; + } +} else { + @colors = @{ $result{'colors'} }; +} + +# Adjust color index if greater than colors length +$color_idx = $result{'color_idx'}; +if ($color_idx >= scalar(@colors)) { + $color_idx = scalar(@colors) - 1; +} + +# Full text, short text, color +print "$result{'val'}\n"; +print "$result{'val'}\n"; + +if (!$ENV{'NO_COLOR'}) { + print "$colors[$color_idx]\n"; +} diff --git a/purpleair/purpleair.png b/purpleair/purpleair.png new file mode 100644 index 00000000..b159e3b7 Binary files /dev/null and b/purpleair/purpleair.png differ diff --git a/rofi-calendar/README.md b/rofi-calendar/README.md index 1fa748e0..e5671ebf 100644 --- a/rofi-calendar/README.md +++ b/rofi-calendar/README.md @@ -21,8 +21,14 @@ Have a minimal calendar pop up in rofi when clicking the date blocklet (right cl [rofi-calendar] command=$SCRIPT_DIR/rofi-calendar interval=3600 -LABEL= -#DATEFTM=+%a. %d. %b. %Y -#SHORTFTM=+%d.%m.%Y +#BAR_POSITION=bottom +#WEEK_START=monday +#DATEFTM=+%a %d %b %Y +#SHORTFMT=+%d/%m/%Y +#LABEL= +#FONT=Monospace 10 +#LEFTCLICK_PREV_MONTH=false +#PREV_MONTH_TEXT=« previous month « +#NEXT_MONTH_TEXT=» next month » +#ROFI_CONFIG_FILE=/dev/null ``` - diff --git a/rofi-calendar/rofi-calendar b/rofi-calendar/rofi-calendar index d4f2ec29..cad4c002 100755 --- a/rofi-calendar/rofi-calendar +++ b/rofi-calendar/rofi-calendar @@ -1,40 +1,144 @@ -#! /bin/sh +#! /usr/bin/env bash -DATEFTM="${DATEFTM:-+%a. %d. %b. %Y}" -SHORTFMT="${SHORTFMT:-+%d.%m.%Y}" -LABEL="${LABEL:-}" -blockdate=$(date "$DATEFTM") -shortblockdate=$(date "$SHORTFMT") +###### Variables ###### +DATEFTM="${DATEFTM:-+%a %d %b %Y}" +SHORTFMT="${SHORTFMT:-+%d/%m/%Y}" +LABEL="${LABEL:- }" +FONT="${FONT:-Monospace 10}" +LEFTCLICK_PREV_MONTH=${LEFTCLICK_PREV_MONTH:-false} +PREV_MONTH_TEXT="${PREV_MONTH_TEXT:-« previous month «}" +NEXT_MONTH_TEXT="${NEXT_MONTH_TEXT:-» next month »}" +ROFI_CONFIG_FILE="${ROFI_CONFIG_FILE:-/dev/null}" +BAR_POSITION="${BAR_POSITION:-bottom}" +WEEK_START="${WEEK_START:-monday}" +###### Variables ###### -year=$(date '+%Y') -month=$(date '+%m') + +###### Functions ###### +# get current date and set today header +get_current_date() { + year=$(date '+%Y') + month=$(date '+%m') + day=$(date '+%d') +} +# print the selected month +print_month() { + mnt=$1 + yr=$2 + cal --color=always --$WEEK_START $mnt $yr \ + | sed -e 's/\x1b\[[7;]*m/\\/g' \ + -e 's/\x1b\[[27;]*m/\<\/u\>\<\/b\>/g' \ + -e '/^ *$/d' \ + | tail -n +2 + echo $PREV_MONTH_TEXT$'\n'$NEXT_MONTH_TEXT +} +# increment year and/or month appropriately based on month increment +increment_month() { + # pick increment and define/update delta + incr=$1 + (( delta += incr )) + # for non-current month + if (( incr != 0 )); then + # add the increment + month=$(( 10#$month + incr )) + # normalize month and compute year + if (( month > 0 )); then + (( month -= 1 )) + (( year += month/12 )) + (( month %= 12 )) + (( month += 1 )) + else + (( year += month/12 - 1 )) + (( month %= 12 )) + (( month += 12 )) + fi + fi + # adjust header + if (( delta == 0 )); then + # today's month => show dd/mm/yyyy + header=$(date "$DATEFTM") + else + # not today's month => show mm/yyyy + header=$(cal $month $year | sed -n '1s/^ *\(.*[^ ]\) *$/\1/p') + fi +} +###### Functions ###### + + +###### Main body ###### +get_current_date + +# handle the click +# variables: +# current_row: set means today row is highlighted +# current_row: not set means... +# bias_row == 0: `next month` row is highlighted +# bias_row == -1: `prev month` row is highlighted +# selected: contains the selected row (next or prev month) +# month_page: the month to be printed 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') + 1) + if [[ $LEFTCLICK_PREV_MONTH == true ]]; then + increment_month -1 + bias_row=-1 + else + increment_month 0 + current_row= + fi + ;; + 2) + increment_month 0 + current_row= + ;; + 3) + increment_month +1 + bias_row=0 + ;; esac + +# rofi pop up 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" + 1|2|3) + # as long as prev/next is selected (and the first time also) + while [[ "${selected+xxx}" != "xxx" ]] || [[ $selected =~ ($PREV_MONTH_TEXT|$NEXT_MONTH_TEXT) ]]; do + IFS= + month_page=$(print_month $month $year) + if [[ "${current_row+xxx}" = "xxx" ]]; then + current_row=$(( $(echo $month_page | grep -n ${day#0} | head -n 1 | cut -d: -f1) - 1 )) + else + current_row=$(( $(echo $month_page | wc -l) - 1)) + fi + + # check bar position and adjust anchor accordingly + if [[ $BAR_POSITION = "top" ]]; then + anchor="northeast" + else + anchor="southeast" + fi + + # open rofi and read the selected row + # (add the following option to rofi command with proper config file, if needed) + selected="$(echo $month_page \ + | rofi \ + -dmenu \ + -markup-rows \ + -font $FONT \ + -m -3 \ + -lines $(echo $month_page | wc -l) \ + -width -25 \ + -theme-str '#window {anchor: '"$anchor"'; location: northwest; }' \ + -theme $ROFI_CONFIG_FILE \ + -selected-row $(( current_row + bias_row )) \ + -p "$header")" + # select next/prev month if necessary and prepare row to be highlighted + [[ $selected =~ $PREV_MONTH_TEXT ]] && { increment_month -1; bias_row=-1; } + [[ $selected =~ $NEXT_MONTH_TEXT ]] && { increment_month +1; bias_row=0; } + # get ready for successive next/prev month hits + unset current_row + done +esac + +# print blocklet text +echo $LABEL$(date "$DATEFTM") +echo $LABEL$(date "$SHORTFMT") +###### Main body ###### diff --git a/rofi-calendar/screenshot.png b/rofi-calendar/screenshot.png index 1516eb1a..b57f9624 100644 Binary files a/rofi-calendar/screenshot.png and b/rofi-calendar/screenshot.png differ diff --git a/ssid/README.md b/ssid/README.md new file mode 100644 index 00000000..41f2a5ce --- /dev/null +++ b/ssid/README.md @@ -0,0 +1,15 @@ +# ssid + +Show the SSID of the current wifi connection. +If no instance is specified, wlan0 is used. + +Dependencies: `iw` + +# Config + +``` +[ssid] +command=$SCRIPT_DIR/ssid +#INTERFACE=wlan0 +interval=60 +``` diff --git a/ssid/i3blocks.conf b/ssid/i3blocks.conf new file mode 100644 index 00000000..12f23f4d --- /dev/null +++ b/ssid/i3blocks.conf @@ -0,0 +1,4 @@ +[ssid] +command=$SCRIPT_DIR/ssid +#INTERFACE=wlan0 +interval=60 diff --git a/ssid/ssid b/ssid/ssid new file mode 100755 index 00000000..be92883b --- /dev/null +++ b/ssid/ssid @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Copyright (C) 2020 hseg +# 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. +# Similarly, if the wifi interface exists but no connection is active, show +# nothing +[[ ! -d /sys/class/net/"${INTERFACE}"/wireless || \ + "$(cat /sys/class/net/"$INTERFACE"/operstate)" = 'down' ]] && exit + +#------------------------------------------------------------------------ + +SSID=$(iw "$INTERFACE" info | awk '/ssid/ {$1=""; print $0}') + +#------------------------------------------------------------------------ + +echo "$SSID" # full text +echo "$SSID" # short text +echo "#00FF00" # color diff --git a/sway-focusedwindow/LICENSE b/sway-focusedwindow/LICENSE new file mode 100644 index 00000000..8cdb8451 --- /dev/null +++ b/sway-focusedwindow/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/sway-focusedwindow/README.md b/sway-focusedwindow/README.md new file mode 100644 index 00000000..14b86a93 --- /dev/null +++ b/sway-focusedwindow/README.md @@ -0,0 +1,32 @@ +# sway-focusedwindow + +Displays title of focused window in [Sway WM](https://swaywm.org/) + +![](sway-focusedwindow.png) + +# Requirements + +Dependencies: swaymsg (typically distributed along with sway), [jq](https://github.com/stedolan/jq) + +# Command line arguments + +```bash +sway-focusedwindow [maxlen [alignment]] +``` + +First argument is maximum line length. `0` means unlimited length, i.e. output line can occupy all available space. +Default value: `0`. + +Second argument is alignment. If output line length is lesser than maximum line length, then it will be aligned. +Possible values: `left`, `right`, `center`. +Default value: `center`. + +# Installation + +The recommended i3blocks config is + +```INI +[sway-focusedwindow] +command=$SCRIPT_DIR/sway-focusedwindow 200 center +interval=persist +``` diff --git a/sway-focusedwindow/sway-focusedwindow b/sway-focusedwindow/sway-focusedwindow new file mode 100755 index 00000000..efe7dbbb --- /dev/null +++ b/sway-focusedwindow/sway-focusedwindow @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +maxlen=0 +if [[ $1 ]]; then + maxlen=$1 +fi + +align="center" +if [[ $2 ]]; then + align=$2 +fi + +format() { + if [[ $maxlen == 0 ]]; then + echo "$1" + return 0 + fi + len=${#1} + if [[ $len -ge $maxlen ]]; then + echo "${1:0:${maxlen}}" + else + pad=$(( maxlen - len )) + case "$align" in + "center" ) + pad=$(( pad / 2 )) + printf "%*s%s%*s\n" $pad "" "$1" $pad "" + ;; + "left" ) + printf "%s%*s\n" "$1" $pad "" + ;; + "right" ) + printf "%*s%s\n" $pad "" "$1" + ;; + esac + fi +} + +process() { + while read -r LINE; do + format "$LINE" + done +} + +swaymsg -t get_tree | jq --unbuffered -r '.. | select(.focused?) | .name' | process + +subscribe_query='select(.container.focused and (.change == "focus" or .change == "title")) | .container.name' +swaymsg -m -t SUBSCRIBE "['window']" | jq --unbuffered -r "$subscribe_query" | process diff --git a/sway-focusedwindow/sway-focusedwindow.png b/sway-focusedwindow/sway-focusedwindow.png new file mode 100644 index 00000000..c49b6eed Binary files /dev/null and b/sway-focusedwindow/sway-focusedwindow.png differ diff --git a/systemd_unit/LICENSE b/systemd_unit/LICENSE new file mode 100644 index 00000000..d8cf7d46 --- /dev/null +++ b/systemd_unit/LICENSE @@ -0,0 +1,280 @@ + 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 diff --git a/systemd_unit/README.md b/systemd_unit/README.md new file mode 100644 index 00000000..33c3f1f8 --- /dev/null +++ b/systemd_unit/README.md @@ -0,0 +1,35 @@ +# systemd_unit + +Show the status of a systemd unit as active, inactive or failed. This +blocklet uses dbus-send to get the current state of a systemd +unit. Both system and user units are supported. + +![](systemd_unit.png) + +# Config + +Simple example for dhcpd service: +``` +[dhcpcd_service] +command=$SCRIPT_DIR/systemd_unit +markup=pango +label=dhcpcd: +interval=30 +UNIT_NAME=dhcpcd.service +``` + +Full example for dhcpd service: +``` +[dhcpcd_service] +command=$SCRIPT_DIR/systemd_unit +markup=pango +label=dhcpcd: +interval=30 +UNIT_NAME=dhcpcd.service +USER_UNIT=false +ACTIVE_COLOR=green +INACTIVE_COLOR=orange +FAILED_COLOR=red +``` + +For user units set `USER_UNIT=true` diff --git a/systemd_unit/systemd_unit b/systemd_unit/systemd_unit new file mode 100755 index 00000000..4a370b40 --- /dev/null +++ b/systemd_unit/systemd_unit @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +if [[ $USER_UNIT == "true" ]] +then + bus="--session" +else + bus="--system" +fi + +if [[ -z $FAILED_COLOR ]] +then + FAILED_COLOR=red +fi + +if [[ -z $INACTIVE_COLOR ]] +then + INACTIVE_COLOR=orange +fi + +if [[ -n $ACTIVE_COLOR ]] +then + ACTIVE_COLOR=" color='$ACTIVE_COLOR'" +fi +# echo $FAILED_COLOR + +object_path=$(dbus-send $bus --print-reply --dest=org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager.GetUnit string:"${UNIT_NAME}" | grep -Po '"\K[^"]+') +status=$(dbus-send $bus --dest=org.freedesktop.systemd1 --print-reply "$object_path" org.freedesktop.DBus.Properties.Get string:'org.freedesktop.systemd1.Unit' string:'ActiveState' | grep -oP 'string "\K[^"]+') + +if [[ $status == "failed" ]] +then + echo "$status" +elif [[ $status == "inactive" ]] +then + echo "$status" +else + echo "$status" +fi diff --git a/systemd_unit/systemd_unit.png b/systemd_unit/systemd_unit.png new file mode 100644 index 00000000..78ed2e50 Binary files /dev/null and b/systemd_unit/systemd_unit.png differ diff --git a/tahoe-lafs/tahoe-lafs b/tahoe-lafs/tahoe-lafs index 1457c80b..4a05f917 100755 --- a/tahoe-lafs/tahoe-lafs +++ b/tahoe-lafs/tahoe-lafs @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash NODE_URL=${BLOCK_INSTANCE%/} DISK_AVAIL=$(curl -s "$NODE_URL/statistics?t=json" 2>/dev/null| jq -r '.stats."storage_server.disk_avail"') diff --git a/taskw/LICENSE b/taskw/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/taskw/LICENSE @@ -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/taskw/README.md b/taskw/README.md new file mode 100644 index 00000000..8eb23d53 --- /dev/null +++ b/taskw/README.md @@ -0,0 +1,11 @@ +# Taskwarrior active task blocklet + +This blocklet shows what task(s) you currently have active in TaskWarrior. +The blocklet will display the description of one of the active tasks +and an indication of how many other active tasks you have. + +## Config options + + - `TASKW_MAX_LENGTH` : the number of characters to truncate long task descriptions at + - `TASKW_NOTASK_MSG` : the text to display if there are no active tasks + - `TASKW_SORT_URGENCY` : a boolean to determine whether to display the most urgent active task (or the default behaviour which is to display the task which has been active longest). diff --git a/taskw/i3blocks.conf b/taskw/i3blocks.conf new file mode 100644 index 00000000..f5d3fcb4 --- /dev/null +++ b/taskw/i3blocks.conf @@ -0,0 +1,10 @@ +# taskw +# +# Display active taskwarrior tasks + +[taskw] +command=taskw +interval=15 +TASKW_MAX_LENGTH = 35 +TASKW_NOTASK_MSG="--No task--" +TASKW_SORT_URGENCY=true \ No newline at end of file diff --git a/taskw/taskw b/taskw/taskw new file mode 100755 index 00000000..efdc149f --- /dev/null +++ b/taskw/taskw @@ -0,0 +1,58 @@ +#!/usr/bin/python3 + +import subprocess +import json +import os + + +def _default(name, default="", arg_type=str): + val = default + if name in os.environ: + val = os.environ[name] + return arg_type(val) + + +def strbool(s): + return s.lower() in ["t", "true", "1"] + + +# I don't know who originally wrote these functions, +# but many of the python blocklets in i3blocks-contrib use it. + +# arch-update added this code on 25 March 2018 and as far as I can tell +# this was the earliest use. + + +maxlen = _default("TASKW_MAX_LENGTH", default=35, arg_type=int) +notask_msg = _default("TASKW_NOTASK_MSG", default="No Task", arg_type=str) +urgency_bool = _default("TASKW_SORT_URGENCY", default="", arg_type=strbool) + + +def shorten(string): + if len(string) <= maxlen: + return string + else: + return string[: maxlen - 3] + "..." + + +def main(): + shell_cmd = "task +ACTIVE export" + prcs = subprocess.check_output(shell_cmd, shell=True) + j = json.loads(prcs) + max_urg = 0 + if urgency_bool: + for i in range(len(j)): + if j[i]["urgency"] > j[max_urg]["urgency"]: + max_urg = i + + if len(j) == 0: + bar_text = notask_msg + elif len(j) == 1: + bar_text = shorten(j[max_urg]["description"]) + else: + bar_text = shorten(j[max_urg]["description"]) + " + " + str(len(j) - 1) + return bar_text + + +if __name__ == "__main__": + print(main()) diff --git a/taskw/taskw-screenshot01.png b/taskw/taskw-screenshot01.png new file mode 100644 index 00000000..9b6e134a Binary files /dev/null and b/taskw/taskw-screenshot01.png differ diff --git a/time/i3blocks.conf b/time/i3blocks.conf index 8e93abb4..c19f71cf 100644 --- a/time/i3blocks.conf +++ b/time/i3blocks.conf @@ -2,6 +2,6 @@ command=$SCRIPT_DIR/time interval=1 #TZ_FILE=~/.tz -STRFTIME_FORMAT=%Y-%m-%d %H:%M +STRFTIME_FORMAT=%Y-%m-%d %R TZONES=$DEFAULT_TZ,Brazil/East,Australia/Brisbane,Asia/Calcutta TZ_LABELS=,Brazil,AU,Hyderabad diff --git a/time/time b/time/time index 725fc689..e552a92a 100755 --- a/time/time +++ b/time/time @@ -55,6 +55,7 @@ if (!exists $display_map{$ENV{TZ}}) { } $tz_display = $display_map{$ENV{TZ}}; +binmode(STDOUT, ":utf8"); my $time = strftime($format, localtime()); if ($tz_display eq "") { print "$time\n"; diff --git a/timer_and_stopwatch/LICENSE.md b/timer_and_stopwatch/LICENSE.md new file mode 100644 index 00000000..660ee4ed --- /dev/null +++ b/timer_and_stopwatch/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/timer_and_stopwatch/README.md b/timer_and_stopwatch/README.md new file mode 100644 index 00000000..b65312a3 --- /dev/null +++ b/timer_and_stopwatch/README.md @@ -0,0 +1,29 @@ +# timer_and_stopwatch + +A minimal timer and stopwatch blocklet. Right click switches between the two +functionalities, left click starts/stops the counter, wheel sets the timer +or the initialial stopwatch time. + +![](running_timer.png) + +![](paused_stopwatch.png) + +* Copy the script into your directory of choice, e.g. ~/.i3blocks/blocklets +* Give it execution permission (`chmod +x timer_and_stopwatch`) +* Add the following blocklet to your i3blocks.conf: + +```ini +[timer_and_stopwatch] +# the DEFAULT_MODE variable must be either timer or stopwatch +format=json +interval=1 +#TIMER_LABEL=TM +#STOPWATCH_LABEL=SW +#DEFAULT_MODE=timer +#DEFAULT_STOPWATCH=0 +#DEFAULT_TIMER=60 +#PLAY_LABEL=(playing) +#PAUSE_LABEL=(paused) +#TIMER_LOOP=true +#NEUTRAL_COLOR=#000000 +``` diff --git a/timer_and_stopwatch/paused_stopwatch.png b/timer_and_stopwatch/paused_stopwatch.png new file mode 100644 index 00000000..6ab965f0 Binary files /dev/null and b/timer_and_stopwatch/paused_stopwatch.png differ diff --git a/timer_and_stopwatch/running_timer.png b/timer_and_stopwatch/running_timer.png new file mode 100644 index 00000000..bddfa606 Binary files /dev/null and b/timer_and_stopwatch/running_timer.png differ diff --git a/timer_and_stopwatch/timer_and_stopwatch b/timer_and_stopwatch/timer_and_stopwatch new file mode 100755 index 00000000..e1f3785e --- /dev/null +++ b/timer_and_stopwatch/timer_and_stopwatch @@ -0,0 +1,168 @@ +#! /usr/bin/env bash +###### Default environment variables ###### +STOPWATCH_LABEL=${STOPWATCH_LABEL:-stopwatch} +TIMER_LABEL=${TIMER_LABEL:-timer} +DEFAULT_MODE=${DEFAULT_MODE:-timer} +DEFAULT_STOPWATCH=${DEFAULT_STOPWATCH:-0} +DEFAULT_TIMER=${DEFAULT_TIMER:-60} +PLAY_LABEL=${PLAY_LABEL:-(playing)} +PAUSE_LABEL=${PAUSE_LABEL:-(paused)} +TIMER_LOOP=${TIMER_LOOP:-false} +NEUTRAL_COLOR=${NEUTRAL_COLOR:-#000000} +###### Default environment variables ###### + +###### Functions ###### +error() { + echo Error: "$@" 1>&2 +} + +next_mode() { + mode=$(( (mode + 1) % ${#modes[@]} )) + set_mode +} + +play_pause() { + $running && pause || play +} + +play() { + running=true + status_symbol=$PLAY_LABEL +} + +pause() { + running=false + status_symbol=$PAUSE_LABEL +} + +reset_times() { + unset time + set_mode +} + +set_mode() { + case ${modes[$mode]} in + 'timer' ) + running=false + status_symbol=$PAUSE_LABEL + initial_time=${initial_time-$DEFAULT_TIMER} + time=$initial_time + incr=-1 + ;; + 'stopwatch' ) + running=false + status_symbol=$PAUSE_LABEL + time=${time-$DEFAULT_STOPWATCH} + fgcolor='#FFFFFF' + bgcolor=$NEUTRAL_COLOR + incr=1 + ;; + esac +} + +compute_color() { + t=$1 + hue360=$(( 120*t/initial_time )) + tmp=$(( hue360 % 120 - 60 )) + tmp=$(( (60 - ${tmp#-})*255/60 )) + if (( hue360 < 60 && hue360 >= 0 )); then + R=255 G=$tmp B=0 + elif (( hue360 <= 120 && hue360 >= 60 )); then + R=$tmp G=255 B=0 + fi + printf '#%06X\n' $(( R*16*16*16*16 + G*16*16 + B )) +} + +prettify_time() { + seconds=$time + if (( time >= 60 )); then + minutes=$(( time / 60 )) + seconds=$(( time % 60 )) + (( seconds < 10 )) && seconds=0$seconds + fi + if (( minutes >= 60 )); then + hours=$(( minutes / 60 )) + minutes=$(( minutes % 60 )) + (( minutes < 10 )) && minutes=0$minutes + fi + echo $hours${hours+:}$minutes${minutes+:}$seconds +} +###### Functions ###### + +###### Internal variables ###### +modes=([0]='timer' [1]='stopwatch') +labels=([0]="$TIMER_LABEL" [1]="$STOPWATCH_LABEL") +###### Internal variables ###### + +###### First run initialization ###### +if [[ ! -v time ]]; then + for i in "${!modes[@]}"; do + if [[ "${modes[$i]}" == "$DEFAULT_MODE" ]]; then + mode=$i + fi + done + set_mode +fi +###### First run initialization ###### + +###### Click processing ###### +case $BLOCK_BUTTON in + 1 ) + play_pause + ;; + 2 ) + reset_times + ;; + 3 ) + next_mode + reset_times + pause + ;; + 4 ) + $running && pause + initial_time=$(( initial_time + 1 )) + time=$initial_time + ;; + 5 ) + $running && pause + initial_time=$(( initial_time - 1 )) + time=$initial_time + ;; +esac +###### Click processing ###### + +###### Time increment ###### +$running && time=$(( time + incr )) +if (( mode == 0 )); then + if (( time <= 0 )); then + bgcolor='#FF0000' + fgcolor=$NEUTRAL_COLOR + time=0 + pause + elif (( time > 0 )); then + fgcolor=$(compute_color $time) + bgcolor=$NEUTRAL_COLOR + fi +else + bgcolor=$NEUTRAL_COLOR + fgcolor='#FFFFFF' +fi +full_text="${labels[$mode]} $status_symbol $(prettify_time)" +if (( mode == 0 && time == 0 )); then + $TIMER_LOOP && reset_times && play +fi +###### Time increment ###### + +###### Output ###### +cat << EOF +{"full_text":"$full_text",\ +"status_symbol":"$status_symbol",\ +"time":"$time",\ +"initial_time":"$initial_time",\ +"incr":"$incr",\ +"running":"$running",\ +"mode":"$mode",\ +"color":"$fgcolor",\ +"background":"$bgcolor"} +EOF +###### Output ###### diff --git a/toggle/LICENSE b/toggle/LICENSE new file mode 100644 index 00000000..d159169d --- /dev/null +++ b/toggle/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/toggle/README.md b/toggle/README.md new file mode 100644 index 00000000..765e4c7d --- /dev/null +++ b/toggle/README.md @@ -0,0 +1,49 @@ +# toggle + +Toggle button. Supports arbitrary commands to toggle on, off, and get current +toggle status. + +On: ![](toggle_on.png) + +Off: ![](toggle_off.png) + +# Requirements + +None + +# Configuration + +A toggle config block includes a label and commands for each of: + +* Turning the toggle on +* Turning the toggle off +* Checking the current toggle status (exit code 0 indicates 'on') + +For example, a configuration to toggle the +[wayvnc VNC server](https://github.com/any1/wayvnc) might look like this: + +```INI +[toggle] +label= +command=$SCRIPT_DIR/toggle +interval=once +COMMAND_ON=swaymsg -q exec wayvnc localhost +COMMAND_OFF=kill $(ps -e -o pid -o exe | grep $(which wayvnc) | awk '{print $1}') +COMMAND_STATUS=ps -eo exe | grep $(which wayvnc) +#COLOR_ON=#ffffff +#COLOR_OFF=#5f6368 +``` + +## Configuration Parameters + +Parameter | Description +-------------- | ----------- +COMMAND_ON | Required: The command to turn the toggle 'on' +COMMAND_OFF | Required: The command to turn the toggle 'off' +COMMAND_STATUS | Required: The command to check the current toggle status (exit code 0 indicates currently on) +COLOR_ON | Optional: The color to use when the toggle is 'on'. Uses the default color if unspecified +COLOR_OFF | Optional: The color to use when the toggle is 'off'. Uses dark gray (#555555) if unspecified + +The script takes care of suppressing output from each of the commands. If you +want to run a command that doesn't immediately exit, it will lock the script +unless you ask i3 (or Sway) to run it for you with i3-msg (or swaymsg). diff --git a/toggle/i3blocks.conf b/toggle/i3blocks.conf new file mode 100644 index 00000000..dc8b2ffc --- /dev/null +++ b/toggle/i3blocks.conf @@ -0,0 +1,9 @@ +[toggle] +label= +command=$SCRIPT_DIR/toggle +interval=once +COMMAND_ON=swaymsg -q exec wayvnc localhost +COMMAND_OFF=kill $(ps -e -o pid -o exe | grep $(which wayvnc) | awk '{print $1}') +COMMAND_STATUS=ps -eo exe | grep $(which wayvnc) +#COLOR_ON=#ffffff +#COLOR_OFF=#5f6368 diff --git a/toggle/toggle b/toggle/toggle new file mode 100755 index 00000000..9ff41265 --- /dev/null +++ b/toggle/toggle @@ -0,0 +1,30 @@ +#!/bin/bash + +if [[ -z ${COMMAND_ON} || -z ${COMMAND_OFF} || -z ${COMMAND_STATUS} ]]; then + echo "All of COMMAND_ON, COMMAND_OFF, and COMMAND_STATUS are required" >&2 + exit 1 +fi + +on_cmd=${COMMAND_ON} +off_cmd=${COMMAND_OFF} +status_cmd=${COMMAND_STATUS} + +if (( ${BLOCK_BUTTON:-0} == 1 )); then + eval $status_cmd 2>&1 >/dev/null + if (( $? == 0 )); then + eval $off_cmd 2>&1 >/dev/null + else + eval $on_cmd 2>&1 >/dev/null + fi +fi + +eval $status_cmd 2>&1 >/dev/null +if (( $? == 0 )); then + COLOR=${COLOR_ON} +else + COLOR=${COLOR_OFF:-#555555} +fi + +echo +echo +echo $COLOR diff --git a/toggle/toggle_off.png b/toggle/toggle_off.png new file mode 100644 index 00000000..a4e8c1f6 Binary files /dev/null and b/toggle/toggle_off.png differ diff --git a/toggle/toggle_on.png b/toggle/toggle_on.png new file mode 100644 index 00000000..5c5bb77a Binary files /dev/null and b/toggle/toggle_on.png differ diff --git a/usb/usb b/usb/usb index f74f0e44..cefbc959 100755 --- a/usb/usb +++ b/usb/usb @@ -1,12 +1,13 @@ #!/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. +# 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: @@ -17,10 +18,11 @@ def _default(name, default='', arg_type=str): # 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 +# 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") @@ -33,7 +35,7 @@ PARTITIONLESS_COLOR = _default("PARTITIONLESS_COLOR", "red") PARTITIONLESS_TEXT = _default("PARTITIONLESS_TEXT", "no partitions") SEPARATOR = _default("SEPARATOR", " | ") -# Indicate whether an encrypted partition is locked/unlocked, "" is allowed. +# Indicate whether an encrypted partition is locked/unlocked, "" is allowed. LOCKED_INDICATOR = _default("LOCKED_INDICATOR", "\uf023 ") UNLOCKED_INDICATOR = _default("UNLOCKED_INDICATOR", "\uf09c ") @@ -51,11 +53,11 @@ TRUNCATE_FS_LABELS = _default("TRUNCASE_FS_LABELS", None) 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) - )) + 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 @@ -64,8 +66,8 @@ if IGNORE_LIST: # 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 + # if udev_attributes_dict["DEVNAME"].startswith("/dev/sda"): + # return True return False # Edit this function to ignore devices before the udev attributes are @@ -75,12 +77,12 @@ def fastIgnore(path): return True # E.g. how to to ignore devices whose path begins with /dev/sda - #if path.startswith("/dev/sda"): - # return True + # 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 + # if path in [ "/dev/path1", "/dev/path2", "/dev/path3" ]: + # return True return False ############################################################################### @@ -94,30 +96,39 @@ import argparse def pangoEscape(text): return text.replace("&", "&").replace("<", "<").replace(">", ">") + def getLeafDevicePaths(): - lines = check_output(['lsblk', '-spndo', 'NAME'], universal_newlines=True) + lines = check_output(['lsblk', '-lpno', 'NAME'], universal_newlines=True) lines = lines.split("\n") + lines = filter(lambda s: s[:4]=='/dev', lines) + lines = map(lambda s: s.split(' ')[0], lines) lines = filter(None, lines) return lines + def getKernelName(path): - return check_output(['lsblk', '-ndso', 'KNAME', path], + return check_output(['lsblk', '-lndo', 'KNAME', path], universal_newlines=True).rstrip("\n") + def getDeviceType(path): return check_output(['lsblk', '-no', 'TYPE', path], - universal_newlines=True).strip() + 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", "") @@ -130,48 +141,56 @@ def getFSLabel(path): label = label[TRUNCATE_FS_LABELS:] return label + def getFSOptions(path): lines = check_output(['findmnt', '-no', 'FS-OPTIONS', path], - universal_newlines=True).strip() + 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") + universal_newlines=True).rstrip("\n") + def getSpaceAvailable(path): lines = check_output(['df', '-h', '--output=avail', path], - universal_newlines=True) + 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) + 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: @@ -186,9 +205,10 @@ def getUnlockedCryptOutput(path): spaceAvail = "" kernelName = pangoEscape(getKernelName(path)) parentKernelName = pangoEscape(getParentKernelName(path)) - + block = "[{}{}:{}]" - block = block.format(color, UNLOCKED_INDICATOR, parentKernelName, kernelName) + block = block.format(color, UNLOCKED_INDICATOR, + parentKernelName, kernelName) label = pangoEscape(getFSLabel(path)) if label: @@ -197,15 +217,17 @@ def getUnlockedCryptOutput(path): items = [block, label, mountPoint, spaceAvail] return " ".join(filter(None, items)) + def getSwapOutput(path): return "" -def getUnencryptedPartitionOutput(path): + +def getUnencryptedPartitionOutput(path): mountPoint = getMountPoint(path) if mountPoint: color = MOUNTED_COLOR if isReadOnly(path): - spaceAvail = READONLY_INDICATOR + spaceAvail = READONLY_INDICATOR else: spaceAvail = pangoEscape(getSpaceAvailable(path)) mountPoint = "{}:".format(pangoEscape(mountPoint)) @@ -224,11 +246,13 @@ def getUnencryptedPartitionOutput(path): 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) @@ -244,14 +268,15 @@ def getOutput(path): return getDiskWithNoPartitionsOutput(path) elif t == "crypt": return getUnlockedCryptOutput(path) - elif t == "rom" : + elif t == "rom": return "" + def makeAttributeMap(path): attributeMap = {} lines = check_output( - ['udevadm','info','--query=property','--name={}'.format(path)], - universal_newlines=True) + ['udevadm', 'info', '--query=property', '--name={}'.format(path)], + universal_newlines=True) lines = lines.split("\n") for line in lines: if line: @@ -259,102 +284,107 @@ def makeAttributeMap(path): attributeMap[key] = val return attributeMap + def getAttributeMaps(paths): - return {path : makeAttributeMap(path) for path in 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/") + dsc = " ".join(["i3blocks blocklet script", + "to output connected usb storage device info"]) + parser = argparse.ArgumentParser(prog="usb.py", description=dsc) + + def unArg(flag, text, default, *args, **kwargs): + parser.add_argument(flag, nargs=1, + help="{}. Default: {}" + .format(text, default), *args, **kwargs) + + def unArgs(flagTempl, textTempl, vals): + for flag, text, default in vals: + unArg(flagTempl.format(flag), textTempl.format(text), default) + + unArgs("--{}-color", "Set the color of {}", + [("info-text", "info text", INFO_TEXT_COLOR), + ("mounted", "mounted devices", MOUNTED_COLOR), + ("plugged", "plugged devices", PLUGGED_COLOR), + ("locked", "locked crypt devices", LOCKED_COLOR), + ("unlocked-not-mounted", "unlocked not mounted crypt devices", + UNLOCKED_NOT_MOUNTED_COLOR), + ("partitionless", "devices with no partitions", + PARTITIONLESS_COLOR) + ]) + + unArg("--partitionless-text", + "Set the text to display for a device with no partitions", + PARTITIONLESS_TEXT) + unArg("--separator", "Set the separator between devices", SEPARATOR) + + unArgs("--{}-indicator", "Set the indicator to use for {}", + [("locked", "a locked crypt device", LOCKED_INDICATOR), + ("unlocked", "an unlocked crypt device", UNLOCKED_INDICATOR), + ("readonly", "a readonly device", READONLY_INDICATOR) + ]) + + unArg("--truncate-fs-labels", + "(integer) Trucate device labels to a certain number of characters", + TRUNCATE_FS_LABELS, type=int) + ignoreText = " ".join([ + "Ignore a device by path.", + "If path doesn't begin with / then it is assumed to be in /dev/"]) + parser.add_argument("-i", "--ignore", action="append", help=ignoreText) args = parser.parse_args() setParsedArgs(args) - + + def setParsedArgs(args): - if args.info_text_color != None: + if args.info_text_color is not None: global INFO_TEXT_COLOR INFO_TEXT_COLOR = args.info_text_color[0] - if args.mounted_color != None: + if args.mounted_color is not None: global MOUNTED_COLOR MOUNTED_COLOR = args.mounted_color[0] - if args.plugged_color != None: + if args.plugged_color is not None: global PLUGGED_COLOR PLUGGED_COLOR = args.plugged_color[0] - if args.locked_color != None: + if args.locked_color is not None: global LOCKED_COLOR LOCKED_COLOR = args.locked_color[0] - if args.unlocked_not_mounted_color != None: + if args.unlocked_not_mounted_color is not None: global UNLOCKED_NOT_MOUNTED_COLOR UNLOCKED_NOT_MOUNTED_COLOR = args.unlocked_not_mounted_color[0] - if args.partitionless_color != None: + if args.partitionless_color is not None: global PARTITIONLESS_COLOR PARTITIONLESS_COLOR = args.partitionless_color[0] - if args.partitionless_text != None: + if args.partitionless_text is not None: global PARTITIONLESS_TEXT PARTITIONLESS_TEXT = args.partitionless_text[0] - if args.separator != None: + if args.separator is not None: global SEPARATOR SEPARATOR = args.separator[0] - if args.locked_indicator != None: + if args.locked_indicator is not None: global LOCKED_INDICATOR LOCKED_INDICATOR = args.locked_indicator[0] - if args.unlocked_indicator != None: + if args.unlocked_indicator is not None: global UNLOCKED_INDICATOR UNLOCKED_INDICATOR = args.unlocked_indicator[0] - if args.readonly_indicator != None: + if args.readonly_indicator is not None: global READONLY_INDICATOR READONLY_INDICATOR = args.readonly_indicator[0] - if args.truncate_fs_labels != None: + if args.truncate_fs_labels is not 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)) + if args.ignore is not 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)] diff --git a/user/README.md b/user/README.md new file mode 100644 index 00000000..547bafb8 --- /dev/null +++ b/user/README.md @@ -0,0 +1,23 @@ +# user + +Show current user name. + +![](user.png) + +Set you user name via this command: +`sudo usermod -c "YOUR NAME" $USER` + +# Dependencies + +* `fontawesome. Not necessary but better install it` + +# Config + +``` +[user] +#label= # Install fontawesome for use this +label=User: +command=lslogins | grep $USER | awk '{print $5,$NF}' +interval=once +``` + diff --git a/user/i3blocks.conf b/user/i3blocks.conf new file mode 100644 index 00000000..766fade2 --- /dev/null +++ b/user/i3blocks.conf @@ -0,0 +1,5 @@ +[user] +#label= # Install fontawesome for use this +label=User: +command=lslogins | grep $USER | awk '{print $5,$NF}' +interval=once diff --git a/user/user.png b/user/user.png new file mode 100644 index 00000000..68fa52ad Binary files /dev/null and b/user/user.png differ diff --git a/volume-pulseaudio/README.md b/volume-pulseaudio/README.md index 75bffdeb..6ff9d183 100644 --- a/volume-pulseaudio/README.md +++ b/volume-pulseaudio/README.md @@ -1,7 +1,7 @@ # volume-pulseaudio Display the system volume and -optionally the default playback device and indeax. +optionally the default playback device and index. Offers controls for these via clicks/scrolling. Supports changing audiostreams that are already playing. @@ -22,7 +22,7 @@ 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 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 ``` diff --git a/volume-pulseaudio/volume-pulseaudio b/volume-pulseaudio/volume-pulseaudio index ad1b2d12..227e8ca9 100755 --- a/volume-pulseaudio/volume-pulseaudio +++ b/volume-pulseaudio/volume-pulseaudio @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Displays the default device, volume, and mute status for i3blocks set -a @@ -118,8 +118,8 @@ function print_format { } 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 '*') + ACTIVE=$(pacmd list-sinks | grep "state\: RUNNING" -B4 -A7 | grep "index:\|name:\|volume: \(front\|mono\)\|muted:") + [ -z "$ACTIVE" ] && ACTIVE=$(pacmd list-sinks | grep "index:\|name:\|volume: \(front\|mono\)\|muted:" | grep -A3 '*') for name in INDEX NAME VOL MUTED; do read $name done < <(echo "$ACTIVE") diff --git a/volume/README.md b/volume/README.md index 66e15a47..0778daca 100644 --- a/volume/README.md +++ b/volume/README.md @@ -36,6 +36,7 @@ signal=10 #STEP=5% #MIXER=[determined automatically] #SCONTROL=[determined automatically] +#NATURAL_MAPPING=0 ``` For PulseAudio users, MIXER is usually "pulse" or "default". For Jack/Jack2 users, MIXER is usually "jackplug". @@ -43,3 +44,6 @@ 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`. + +If `NATURAL_MAPPING` is set to a non-zero value, the `-M` flag is used for `amixer`, enabling +a volume mapping more natural for the human ear, as used in alsamixer. diff --git a/volume/volume b/volume/volume index 6e0c4fe6..e8e1372a 100755 --- a/volume/volume +++ b/volume/volume @@ -50,15 +50,23 @@ if [[ -z "$STEP" ]] ; then STEP="${1:-5%}" fi +# AMIXER(1): +# "Use the mapped volume for evaluating the percentage representation like alsamixer, to be +# more natural for human ear." +NATURAL_MAPPING=${NATURAL_MAPPING:-0} +if [[ "$NATURAL_MAPPING" != "0" ]] ; then + AMIXER_PARAMS="-M" +fi + #------------------------------------------------------------------------ capability() { # Return "Capture" if the device is a capture device - amixer -D $MIXER get $SCONTROL | + amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL | sed -n "s/ Capabilities:.*cvolume.*/Capture/p" } volume() { - amixer -D $MIXER get $SCONTROL $(capability) + amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL $(capability) } format() { @@ -75,9 +83,9 @@ format() { #------------------------------------------------------------------------ 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 + 3) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute + 4) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase + 5) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease esac volume | format diff --git a/wifi/i3blocks.conf b/wifi/i3blocks.conf index e2071732..e11767bf 100644 --- a/wifi/i3blocks.conf +++ b/wifi/i3blocks.conf @@ -3,3 +3,8 @@ command=$SCRIPT_DIR/wifi label=wifi: #INTERFACE=wlan0 interval=60 +#COLOR_GE80=#00FF00 +#COLOR_GE60=#FFF600 +#COLOR_GE40=#FFAE00 +#COLOR_LOWR=#FF0000 +#COLOR_DOWN=#FF0000 diff --git a/wifi/wifi b/wifi/wifi index 34b63482..258ac8ce 100755 --- a/wifi/wifi +++ b/wifi/wifi @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright (C) 2014 Alexander Keller # This program is free software: you can redistribute it and/or modify @@ -20,6 +20,12 @@ if [[ -z "$INTERFACE" ]] ; then fi #------------------------------------------------------------------------ +COLOR_GE80=${COLOR_GE80:-#00FF00} +COLOR_GE60=${COLOR_GE60:-#FFF600} +COLOR_GE40=${COLOR_GE40:-#FFAE00} +COLOR_LOWR=${COLOR_LOWR:-#FF0000} +COLOR_DOWN=${COLOR_DOWN:-#FF0000} + # 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 @@ -28,13 +34,13 @@ fi if [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]]; then echo "down" echo "down" - echo "#FF0000" + echo $COLOR_DOWN exit fi #------------------------------------------------------------------------ -QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') +QUALITY=$(iw dev ${INTERFACE} link | grep 'dBm$' | grep -Eoe '-[0-9]{2}' | awk '{print ($1 > -50 ? 100 :($1 < -100 ? 0 : ($1+100)*2))}') #------------------------------------------------------------------------ @@ -43,11 +49,11 @@ echo $QUALITY% # short text # color if [[ $QUALITY -ge 80 ]]; then - echo "#00FF00" + echo $COLOR_GE80 elif [[ $QUALITY -ge 60 ]]; then - echo "#FFF600" + echo $COLOR_GE60 elif [[ $QUALITY -ge 40 ]]; then - echo "#FFAE00" + echo $COLOR_GE40 else - echo "#FF0000" + echo $COLOR_LOWR fi diff --git a/xkb_layout/LICENSE b/xkb_layout/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/xkb_layout/LICENSE @@ -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/xkb_layout/README.md b/xkb_layout/README.md new file mode 100644 index 00000000..e8a0c68f --- /dev/null +++ b/xkb_layout/README.md @@ -0,0 +1,34 @@ +# xkb_layout + +Keyboard layout indicator. + +Monitors for layout change and refreshes on its own without need for signals from i3blocks. Does not handle clicks or switch layouts. + +![block preview](xkb_layout.png) + +# Requires: + + - [xkb-switch](https://github.com/ierton/xkb-switch) utility, should be in your distro's package repository under the same name. + + - A standard X11 way of switching layouts you would use anyways: + +``` +exec --no-startup-id "setxkbmap -layout us,ru -option 'grp:alt_shift_toggle'" +``` + +The above line needs to be executed after X session startup, add it to `~/.config/i3/config` or `~/.xsession` or any other place you manage startup apps and scripts in. + +# i3blocks config example: + +```ini +[xkb_layout] +command=$SCRIPT_DIR/xkb_layout +font=monospace +font_weight=bold +interval=persist +markup=pango +``` + +`font` must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant font name. If not set, 'monospace' is used as default. + +`font_weight` must be a [pango markup](https://developer.gnome.org/pygtk/stable/pango-markup-language.html) compliant font weight. If not set, 'bold' is used as default. diff --git a/xkb_layout/xkb_layout b/xkb_layout/xkb_layout new file mode 100755 index 00000000..17f784f1 --- /dev/null +++ b/xkb_layout/xkb_layout @@ -0,0 +1,16 @@ +#!/usr/bin/env sh +# This script is supposed to be used as an i3blocks persistent blocklet. +# It outputs current keyboard layout, then waits for it to change in an infinite loop. +# Requires `xkb-switch` utility. Should work in any *sh. +# Written by skidnik +# +# Defaults: +font=${font:-monospace} +font_weight=${font_weight:-bold} +while : +do +# Output current layout: + xkb-switch -p | awk -v font="$font" -v font_weight="$font_weight" '{print ""toupper($0)""}' || sleep 1 +# Wait for layout change: + xkb-switch -w +done diff --git a/xkb_layout/xkb_layout.png b/xkb_layout/xkb_layout.png new file mode 100644 index 00000000..1e3f25df Binary files /dev/null and b/xkb_layout/xkb_layout.png differ