From fa5f28ca3f90c9ce6b26d1841f72623ab490f19d Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 13 Jan 2022 21:57:24 -0700 Subject: [PATCH] update zenUtils --- README.md | 16 +++++++++++ desks.sh | 40 ++++++++++++++++++++++++++ dynacal.sh | 25 ++++++++++++++++ extdisplay.sh | 10 ++++++- logout.sh | 2 +- t2stats.sh | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ xtraKeys.sh | 39 +++++++++++++++++++++++++ 7 files changed, 209 insertions(+), 2 deletions(-) create mode 100755 desks.sh create mode 100755 dynacal.sh create mode 100755 t2stats.sh create mode 100755 xtraKeys.sh diff --git a/README.md b/README.md index 129fcc4..ebe4a3a 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,22 @@ Generate a timesheet for a given month by manipulating the output from `zeit` 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. diff --git a/desks.sh b/desks.sh new file mode 100755 index 0000000..8df6abd --- /dev/null +++ b/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 +# 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 diff --git a/dynacal.sh b/dynacal.sh new file mode 100755 index 0000000..c2adb5d --- /dev/null +++ b/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 diff --git a/extdisplay.sh b/extdisplay.sh index c70e290..b6e5c65 100755 --- a/extdisplay.sh +++ b/extdisplay.sh @@ -7,9 +7,10 @@ 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" @@ -38,6 +39,13 @@ elif [ "$1" = off ]; then 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 right-of|left-of|above|below) diff --git a/logout.sh b/logout.sh index 86c202d..b0afacc 100755 --- a/logout.sh +++ b/logout.sh @@ -34,7 +34,7 @@ handler() { elif pgrep ryudo; then killall ryudo else - killall -0 Xorg + killall fluxbox fi ;; hibernate) diff --git a/t2stats.sh b/t2stats.sh new file mode 100755 index 0000000..b1c790c --- /dev/null +++ b/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 +# 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 diff --git a/xtraKeys.sh b/xtraKeys.sh new file mode 100755 index 0000000..0fe08fe --- /dev/null +++ b/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