From: Tucker Johnson Date: Sat, 16 May 2026 12:34:21 +0000 (-0400) Subject: for-script X-Git-Url: https://git.newer.systems/?a=commitdiff_plain;h=refs%2Fheads%2Fmain;p=dwmblocks.git for-script --- diff --git a/Makefile b/Makefile index 9ee494d..32c9294 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,6 @@ install: dwmblocks chmod 755 $(DESTDIR)$(PREFIX)/bin/sb-memory chmod 755 $(DESTDIR)$(PREFIX)/bin/sb-nettraf chmod 755 $(DESTDIR)$(PREFIX)/bin/sb-volume - chmod 755 $(DESTDIR)$(PREFIX)/bin/sb-weather uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/dwmblocks\ $(DESTDIR)$(PREFIX)/bin/sb-* diff --git a/config.h b/config.h index 29ceb3d..9836d9e 100644 --- a/config.h +++ b/config.h @@ -2,12 +2,11 @@ static const Block blocks[] = { /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ {"", "cat /tmp/recordingicon 2>/dev/null", 0, 9}, -/* {"", "sb-weather", 600, 19}, */ {"", "sb-memory", 10, 14}, /* {"", "sb-cpu", 10, 18}, */ {"", "sb-volume", 0, 10}, {"", "sb-nettraf", 1, 16}, - {"", "sb-internet", 5, 4}, + {"", "sb-internet", 30, 4}, /*uncomment for laptops:*/ /* {"", "sb-battery", 5, 3}, */ {"", "sb-clock", 60, 1}, diff --git a/statusbar-scripts/sb-battery b/statusbar-scripts/sb-battery index 56d390d..27bb68c 100755 --- a/statusbar-scripts/sb-battery +++ b/statusbar-scripts/sb-battery @@ -2,11 +2,11 @@ case $BLOCK_BUTTON in 3) notify-send " Battery" ": discharging -: not charging -: stagnant charge -: charging -: charged -: battery very low! +❗: not charging +🔴: stagnant charge +🔌: charging +🔋: charged +🪫: battery very low! - Scroll to change adjust xbacklight." ;; 4) xbacklight -inc 10 ;; 5) xbacklight -dec 10 ;; @@ -19,10 +19,10 @@ for battery in /sys/class/power_supply/BAT?*; do [ -n "${capacity+x}" ] && printf " " # Sets up the status and capacity case "$(cat "$battery/status" 2>&1)" in - "Full") status="" ;; - "Discharging") status="" ;; - "Charging") status="" ;; - "Not charging") status="" ;; + "Full") status="🔋" ;; + "Discharging") status="🪫" ;; + "Charging") status="🔌" ;; + "Not charging") status="❗" ;; "Unknown") status="?" ;; *) exit 1 ;; esac diff --git a/statusbar-scripts/sb-clock b/statusbar-scripts/sb-clock index 533d9fd..be7fcf3 100755 --- a/statusbar-scripts/sb-clock +++ b/statusbar-scripts/sb-clock @@ -18,7 +18,7 @@ case $BLOCK_BUTTON in done <<< "$input" notify-send "$summary" "$current_block" ;; - 3) notify-send " time/date" "\- displays time and date + 3) notify-send "🕰️ time/date" "\- displays time and date \- left click to show schedule for current day using remind and to-do list" ;; 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; esac diff --git a/statusbar-scripts/sb-internet b/statusbar-scripts/sb-internet index 76cce17..76197b2 100755 --- a/statusbar-scripts/sb-internet +++ b/statusbar-scripts/sb-internet @@ -1,27 +1,43 @@ #!/bin/sh case $BLOCK_BUTTON in - 3) notify-send " internet" ": wifi disabled -: no wifi connection -: wifi connection with quality -: no ethernet -: ethernet working -: vpn is active + 3) notify-send " internet" ": wifi disabled +: no wifi connection +: wifi connection with quality +: no ethernet +: ethernet working +: vpn is active " ;; 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; esac -# Wifi -if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then - wifiicon="$(awk '/^\s*w/ { print "", int($3 * 100 / 70) "% " }' /proc/net/wireless)" -elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then - [ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="📶" || wifiicon="" -fi +# Wifi - iterate in case of multiple interfaces +wifiicon="" +for iface in /sys/class/net/w*/operstate; do + [ -f "$iface" ] || continue + state=$(cat "$iface") + name="${iface%/operstate}" + name="${name##*/}" + if [ "$state" = 'up' ]; then + wifiicon="$(awk "/^\s*${name}/ { print \"\", int(\$3 * 100 / 70) \"% \" }" /proc/net/wireless)" + break + elif [ "$state" = 'down' ]; then + [ "$(cat "/sys/class/net/${name}/flags" 2>/dev/null)" = '0x1003' ] && wifiicon="📶" || wifiicon="" + fi +done -# Ethernet -[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="🌐" || ethericon="" +# Ethernet - iterate in case of multiple interfaces +ethericon="" +for iface in /sys/class/net/e*/operstate; do + [ -f "$iface" ] || continue + [ "$(cat "$iface")" = 'up' ] && ethericon="🌐" && break +done -# TUN -[ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon="" +# VPN - tun* or tailscale* +tunicon="" +for iface in /sys/class/net/tun*/operstate /sys/class/net/tailscale*/operstate; do + [ -f "$iface" ] || continue + [ "$(cat "$iface")" != 'down' ] && tunicon="🔒" && break +done printf "[%s%s%s]\n" "$wifiicon" "$ethericon" "$tunicon" diff --git a/statusbar-scripts/sb-nettraf b/statusbar-scripts/sb-nettraf index 75e8d14..f5e052d 100755 --- a/statusbar-scripts/sb-nettraf +++ b/statusbar-scripts/sb-nettraf @@ -1,7 +1,7 @@ #!/bin/sh case $BLOCK_BUTTON in - 3) notify-send " network traffic" "\- shows download/upload Traffic" ;; + 3) notify-send "🌐 network traffic" "\- shows download/upload Traffic" ;; 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; esac diff --git a/statusbar-scripts/sb-weather b/statusbar-scripts/sb-weather deleted file mode 100755 index b5486d2..0000000 --- a/statusbar-scripts/sb-weather +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -case $BLOCK_BUTTON in - 1) notify-send "🌦️ weather" "$(curl 'wttr.in/Brockport?format=%l:+\n%C+%c\nfeels-like:%f+actual:%t\nsunrise:%S+sunset:%s\n')" ;; - 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -echo ["$(curl 'wttr.in/Brockport?format=%f+%C\n')"]