commit 500da620557e19c334882e50ffbd92d6e53a4b76
parent af818b134f81cb25fbc6bd1c969c39f7920500ef
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Wed, 10 Jul 2024 11:51:20 +0200
status for OpenBSD
Diffstat:
4 files changed, 33 insertions(+), 39 deletions(-)
diff --git a/Makefile b/Makefile
@@ -35,6 +35,8 @@ SCRIPTS = addressgrep \
share \
spawn \
status \
+ status-openbsd \
+ status-void \
templess \
terminal \
translate \
diff --git a/status b/status
@@ -1,41 +1,13 @@
#!/bin/sh
-# Prints some status info to stdout. Includes:
-# - date and time
-# - battery
-# - wifi (requires nmcli)
-# - past notifications (requires notify)
-
-# Usage: status [separator]
-
-sep=${1:-" | "}
-
-time=$(date +"%H:%M")
-date=$(date +"%d %B %Y, %A")
-
-if [ "$(pulsemixer --get-mute)" -eq 1 ]; then
- volume="Audio muted"
-else
- volume="Volume: $(pulsemixer --get-volume | awk '{print $1}')%"
-fi
-
-bat="/sys/class/power_supply/BAT0"
-if [ -d $bat ]; then
- battery="Battery: $(cat $bat/capacity)% $(cat $bat/status)"
-else
- battery="No battery"
-fi
-
-# NetworkManager has a dreadful command line interface
-# It makes cry every time
-# pls help
-nwline="$(nmcli device status | head -n 2 | tail -n 1)"
-nwclean="$(echo "$nwline" | sed 's/ *$//' | sed 's/.* //')"
-network="Network: $nwclean"
-
-noticount=$(notify show | wc -l)
-
-printf '%s' "$network$sep$volume$sep$battery$sep$date$sep$time"
-[ "$noticount" = "1" ] && printf '%s' "$sep$(notify show)"
-[ "$noticount" -gt "1" ] && printf '%s' "${sep}Unread items: $noticount"
-printf '\n'
+# Calls one of the system-specific status scripts to display
+# a line of text with some status information (battery, date...)
+
+case "$(uname)" in
+OpenBSD)
+ status-openbsd
+ ;;
+*)
+ status-void
+ ;;
+esac
diff --git a/status-openbsd b/status-openbsd
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Prints some status info to stdout. Includes:
+# - date and time
+# - battery
+# - wifi (requires ifconfig on OpenBSD)
+
+# Usage: status [separator]
+
+sep=${1:-" | "}
+
+time=$(date +"%H:%M")
+date=$(date +"%d %B %Y")
+battery="$(apm | grep -o '[^ ]*%')"
+network="$(ifconfig athn0 | grep status | sed 's/.*status: //')"
+if [ "$network" = "active" ]; then
+ network="$(ifconfig athn0 | grep nwid | sed 's/.*nwid //;s/ chan.*//')"
+fi
+
+echo "$network$sep$battery$sep$date$sep$time"
diff --git a/status b/status-void