From 500da620557e19c334882e50ffbd92d6e53a4b76 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 10 Jul 2024 11:51:20 +0200 Subject: status for OpenBSD --- Makefile | 2 ++ status | 50 +++++++++++--------------------------------------- status-openbsd | 20 ++++++++++++++++++++ status-void | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 39 deletions(-) create mode 100755 status-openbsd create mode 100755 status-void diff --git a/Makefile b/Makefile index 1a14061..1bd4892 100644 --- 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 index fcc4c28..44935cd 100755 --- 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 new file mode 100755 index 0000000..1f88b50 --- /dev/null +++ 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-void b/status-void new file mode 100755 index 0000000..fcc4c28 --- /dev/null +++ b/status-void @@ -0,0 +1,41 @@ +#!/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' -- cgit v1.3