]> git.newer.systems Git - dwmblocks.git/commitdiff
for-script main
authorTucker Johnson <tucker@newer.systems>
Sat, 16 May 2026 12:34:21 +0000 (08:34 -0400)
committerTucker Johnson <tucker@newer.systems>
Sat, 16 May 2026 12:34:21 +0000 (08:34 -0400)
Makefile
config.h
statusbar-scripts/sb-battery
statusbar-scripts/sb-clock
statusbar-scripts/sb-internet
statusbar-scripts/sb-nettraf
statusbar-scripts/sb-weather [deleted file]

index 9ee494df0fcde8ad37972ee42bae04bbcc18c5ba..32c9294738a9dffe2f158c93f57f25b9a58294fe 100644 (file)
--- 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-*
index 29ceb3db2479ac2540e776cb813f705ff3e94cf4..9836d9ea8ce87098137e235c0e4b4d7ef1777961 100644 (file)
--- 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},
index 56d390d478b9763bc1039ea8c611d43282d27a47..27bb68cd88b604eb5af031b02f1f20b74e11add9 100755 (executable)
@@ -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
index 533d9fd85c96706b434e2ff2d132db89dbea8f14..be7fcf33cb0c6d84135aa783899848637b698e1c 100755 (executable)
@@ -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
index 76cce17de1b4fb7c73f75fd625bd22e33f441b37..76197b27c97a610d57711a1736bee12d9ee84488 100755 (executable)
@@ -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"
index 75e8d14ed7286cd9e9278a13af66b34799a72c53..f5e052d677360a2e3311d981c8dd6be28d8151f8 100755 (executable)
@@ -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 (executable)
index b5486d2..0000000
+++ /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')"]