all repos — zenUtils @ fa5f28ca3f90c9ce6b26d1841f72623ab490f19d

misc utilities for computing zen

update zenUtils
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAmHhArQACgkQO3+8IhRO
Y5gqbA/+PZ3IiGa6O3mdoydun5mWlwCh778Z15qpnPeagNQEDxNrPqutY6w027z6
5mE76IBH3A12OyYp3PVTX44f9SmO+ohcJB70BPrdbBKuvvpDhW9SMc/CXnhGs8gm
x59Ati+A/eATZvTtrZi6zKsVgBnp/M7xuIr0TdWLt1w8eSrg64dq489jvzgWuyc1
S2PUbC9vOvWj/FP3U6HbV+JefnRq3akfFMN1yGuNXSt7eMBvwMDGGxnu1c5JQsBa
dbEf2gtNCizuC17alWDPTOH2QXk19EM+L3aVaPp8V5KuR2JL9DE6IgnA1cpxXQ0q
KcELYR7K7J8e2wxTcDUdSpM3IXNsub11wozkcBroBEHHEyLzlQooDaXYf7FgDHDM
/mCm5wDtDJbQ954kU1ZjAKMGJA/Z8P+XZURa21cc+8ekxoCKm2t2MTsxLycK1wSB
AM/GS2LOSe6pZKB8JJWsjvsnEL6+VL/Sr+ma197B3cnkh6EJOZuS+sFJWm6cdKuB
dRpUMTA/NrkOZy00oYQemMw0SNTFOuy/dmOL0CuY1JLpALCxVuz8zyngfCQ7NbXt
Hq+SvAsRWyLBTZl403Gn1wLgGwY4UYUgNCyC1ZDV2ZUWuMZPJanR2kgtTBqfeS2J
Fmpc7mamPNmTqoF3nSg6XQSHpwHMUKobnc73wfQGYui0Nc3duxY=
=02iU
-----END PGP SIGNATURE-----
commit

fa5f28ca3f90c9ce6b26d1841f72623ab490f19d

parent

72ef08cc8c594ec701497ba4db4be70677fca355

7 files changed, 209 insertions(+), 2 deletions(-)

jump to
M README.mdREADME.md

@@ -38,6 +38,22 @@ ### riosh

Shell script to loosley emulate `rio` behavior in a EWMH-compliant WM +### desks + +shell script to facilitate desktop switching via a tint2 executor + +### xtraKeys + +common keybinding operations with notifications + +### t2stats + +tint2 system load/memory, battery, and network info + +### dynaclock + +displays either regular or arvelie clock in a tint2 executor, with an action to switch them as well + ## License This collection is released permissively under the MIT License. You can do whatever you want with it, as long as you leave my name on it.
A desks.sh

@@ -0,0 +1,40 @@

+#!/bin/sh + +# this is a simple script to both give some semblance of eye-candy for a tint2 executor +# and to switch virtual desktops programmatically, to be invoked by button click/scroll +# on said executor. +# copyleft 2020 Derek Stevens <drkste@zoho.com> +# MIT License - do whatever you want + +# if we're feeling spartan, just print a simple string for the executor +if [ -z $1 ]; then + echo "" + +# if we pass '-x', spit a few hexadecimal bytes into the executor for eye-candy +elif [ "$1" = "-x" ]; then + od -vAn -N2 -x < /dev/urandom + +# otherwise switch desks +else + currentDeskNum=$(wmctrl -d | grep -n [*] | awk '{print $1}' | awk -F : '{print $1}') + numDesks=$(wmctrl -d | wc -l) + + case $1 in + "-n") + if [ ${currentDeskNum} -eq ${numDesks} ]; then + newDesk=$(wmctrl -d | head -n 1 | awk '{print $1}') + else + newDesk=$(wmctrl -d | head -n $((currentDeskNum + 1)) | tail -n 1 | awk '{print $1}') + fi + ;; + "-p") + if [ ${currentDeskNum} -eq 1 ]; then + newDesk=$(wmctrl -d | tail -n 1 | awk '{print $1}') + else + newDesk=$(wmctrl -d | head -n $((currentDeskNum - 1)) | tail -n 1 | awk '{print $1}') + fi + ;; + esac + + wmctrl -s ${newDesk} +fi
A dynacal.sh

@@ -0,0 +1,25 @@

+#!/bin/sh + +if [ "$1" = "-t" ]; then + current=$(cat ~/.time_mode) + case ${current} in + "common") + echo "regular" > ~/.time_mode + ;; + *) + echo "common" > ~/.time_mode + ;; + esac +fi + +if [ -z "$1" ]; then + mode=$(cat ~/.time_mode) + case ${mode} in + "regular") + echo "[$(~/bin/arvelie) $(~/bin/neralie -s)]" + ;; + *) + echo "[$(date +"%F %H:%M")]" + ;; + esac +fi
M extdisplay.shextdisplay.sh

@@ -7,9 +7,10 @@ # MIT License -- do whatever you want

helpme() { - echo "$0, wrapper for using xrandr to handle an external on a laptop" + echo "$0, wrapper for using xrandr to handle an external display on a laptop" echo "" echo "USAGE: $0 solo|off|left-of|right-of|above|below [res]" + echo " status\n prints connected/disconnected depending on if there is a monitor plugged in" echo " solo\n activates the plugged monitor, deactivates the native display" echo " off\n activates the native display, deactivates the plugged monitor" echo " left-of, right-of, above, below\n activates the plugged monitor in the given"

@@ -37,6 +38,13 @@ elif [ "$1" = off ]; then

xrandr --output ${native} --primary xrandr --output ${plugged} --off xrandr --output ${native} --auto + +elif [ "$1" = status ]; then + if [ -z "$(xrandr | grep connected | grep -v disconnected | grep -v LVDS)" ]; then + echo "disconnected" + else + echo "connected" + fi else case $1 in
M logout.shlogout.sh

@@ -34,7 +34,7 @@ killall sddm-helper

elif pgrep ryudo; then killall ryudo else - killall -0 Xorg + killall fluxbox fi ;; hibernate)
A t2stats.sh

@@ -0,0 +1,79 @@

+#!/bin/sh + +# t2stats: +# this is a simple network/battery status indicator to be used with tint2 +# copyleft 2020 Derek Stevens <drkste@zoho.com> +# MIT License -- do whatever you want + +if [ "$1" = "-l" ]; then + load=$(cat /proc/loadavg | awk '{print $1}') + memdata=$(free -h --si | grep Mem) + swapdata=$(free -h --si | grep Swap) + memused=$(echo ${memdata} | awk '{print $3}' ) + swapused=$(echo ${swapdata} | awk '{print $3}') + + echo " ${load} | ${memused} | ${swapused}" +fi + +if [ "$1" = "-r" ]; then + + # network + actives=$(nmcli connection show --active) + possiblywifi=$(echo "${actives}" | grep wifi) + possiblyeth=$(echo "${actives}" | grep Wired) + ORS=" " + + if [ ! -z "${possiblyeth}" ]; then + output=wired + elif [ ! -z "${possiblywifi}" ]; then + output="wifi/$(echo ${possiblywifi} |\ + awk 'BEGIN { ORS=" " }; {for (i=1; i<=(NF-3);i++) print $i}')" + else + output=offline + fi + + echo -n "${output}" + + # battery + powerlevel=$(cat /sys/class/power_supply/BAT*/capacity) + case $powerlevel in + 0) + meter=" " + ;; + 1|2|3|4|5|6|7|8|9) + meter=" " + ;; + 10|11|12|13|14|15|16|17|18|19) + meter=" " + ;; + 20|21|22|23|24|25|26|27|28|29) + meter=" " + ;; + 30|31|32|33|34|35|36|37|38|39) + meter=" " + ;; + 40|41|42|43|44|45|46|47|48|49) + meter=" " + ;; + 50|51|52|53|54|55|56|57|58|59) + meter=" " + ;; + 60|61|62|63|64|65|66|67|68|69) + meter=" " + ;; + 70|71|72|73|74|75|76|77|78|79) + meter=" " + ;; + 80|81|82|83|84|85|86|87|88|89) + meter="" + ;; + *) + meter="" + ;; + esac + + if ! grep Full /sys/class/power_supply/BAT*/status > /dev/null \ + && file /sys/class/power_supply/BAT* > /dev/null; then + echo " ${meter}" + fi +fi
A xtraKeys.sh

@@ -0,0 +1,39 @@

+#!/bin/sh + +helpme(){ + echo "$0 < v | b > < args >" + echo " args for v (volume) command:" + echo " u, d, m, mm (up, down, toggle mute, toggle mic mute)" + echo " args for b (brightness) command:" + echo " u, d (up, down)" + exit 1 +} + +if [ -z "$2" ]; then + helpme +fi + +case ${1}${2} in + "vu") + amixer set Master 5%+; notify-send -u low -c volume volume $(amixer get Master | grep % | head -n 1 | awk '{print $5}') + ;; + "vd") + amixer set Master 5%-; notify-send -u low -c volume volume $(amixer get Master | grep % | head -n 1 | awk '{print $5}') + ;; + "vm") + amixer set Master toggle + ;; + "vmm") + amixer set Capture toggle + ;; + "bu") + xbacklight -inc 5; notify-send -u low -c brightness brightness [$(xbacklight -get)%] + ;; + "bd") + xbacklight -dec 5; notify-send -u low -c brightness brightness [$(xbacklight -get)%] + ;; + *) + helpme;; +esac + +exit 0