aboutsummaryrefslogtreecommitdiff
path: root/status
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-07-10 11:51:20 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-07-11 07:19:07 +0200
commit500da620557e19c334882e50ffbd92d6e53a4b76 (patch)
tree5d14def7b61ca31453d5ec66f5bc7f47c0ca6b5d /status
parentaf818b134f81cb25fbc6bd1c969c39f7920500ef (diff)
downloadscripts-500da620557e19c334882e50ffbd92d6e53a4b76.tar.gz
scripts-500da620557e19c334882e50ffbd92d6e53a4b76.zip
status for OpenBSD
Diffstat (limited to '')
-rwxr-xr-xstatus48
-rwxr-xr-xstatus-openbsd20
-rwxr-xr-xstatus-void41
3 files changed, 71 insertions, 38 deletions
diff --git a/status b/status
index fcc4c28..44935cd 100755
--- a/status
+++ b/status
@@ -1,41 +1,13 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# Prints some status info to stdout. Includes: 3# Calls one of the system-specific status scripts to display
4# - date and time 4# a line of text with some status information (battery, date...)
5# - battery
6# - wifi (requires nmcli)
7# - past notifications (requires notify)
8 5
9# Usage: status [separator] 6case "$(uname)" in
10 7OpenBSD)
11sep=${1:-" | "} 8 status-openbsd
12 9 ;;
13time=$(date +"%H:%M") 10*)
14date=$(date +"%d %B %Y, %A") 11 status-void
15 12 ;;
16if [ "$(pulsemixer --get-mute)" -eq 1 ]; then 13esac
17 volume="Audio muted"
18else
19 volume="Volume: $(pulsemixer --get-volume | awk '{print $1}')%"
20fi
21
22bat="/sys/class/power_supply/BAT0"
23if [ -d $bat ]; then
24 battery="Battery: $(cat $bat/capacity)% $(cat $bat/status)"
25else
26 battery="No battery"
27fi
28
29# NetworkManager has a dreadful command line interface
30# It makes cry every time
31# pls help
32nwline="$(nmcli device status | head -n 2 | tail -n 1)"
33nwclean="$(echo "$nwline" | sed 's/ *$//' | sed 's/.* //')"
34network="Network: $nwclean"
35
36noticount=$(notify show | wc -l)
37
38printf '%s' "$network$sep$volume$sep$battery$sep$date$sep$time"
39[ "$noticount" = "1" ] && printf '%s' "$sep$(notify show)"
40[ "$noticount" -gt "1" ] && printf '%s' "${sep}Unread items: $noticount"
41printf '\n'
diff --git a/status-openbsd b/status-openbsd
new file mode 100755
index 0000000..1f88b50
--- /dev/null
+++ b/status-openbsd
@@ -0,0 +1,20 @@
1#!/bin/sh
2
3# Prints some status info to stdout. Includes:
4# - date and time
5# - battery
6# - wifi (requires ifconfig on OpenBSD)
7
8# Usage: status [separator]
9
10sep=${1:-" | "}
11
12time=$(date +"%H:%M")
13date=$(date +"%d %B %Y")
14battery="$(apm | grep -o '[^ ]*%')"
15network="$(ifconfig athn0 | grep status | sed 's/.*status: //')"
16if [ "$network" = "active" ]; then
17 network="$(ifconfig athn0 | grep nwid | sed 's/.*nwid //;s/ chan.*//')"
18fi
19
20echo "$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 @@
1#!/bin/sh
2
3# Prints some status info to stdout. Includes:
4# - date and time
5# - battery
6# - wifi (requires nmcli)
7# - past notifications (requires notify)
8
9# Usage: status [separator]
10
11sep=${1:-" | "}
12
13time=$(date +"%H:%M")
14date=$(date +"%d %B %Y, %A")
15
16if [ "$(pulsemixer --get-mute)" -eq 1 ]; then
17 volume="Audio muted"
18else
19 volume="Volume: $(pulsemixer --get-volume | awk '{print $1}')%"
20fi
21
22bat="/sys/class/power_supply/BAT0"
23if [ -d $bat ]; then
24 battery="Battery: $(cat $bat/capacity)% $(cat $bat/status)"
25else
26 battery="No battery"
27fi
28
29# NetworkManager has a dreadful command line interface
30# It makes cry every time
31# pls help
32nwline="$(nmcli device status | head -n 2 | tail -n 1)"
33nwclean="$(echo "$nwline" | sed 's/ *$//' | sed 's/.* //')"
34network="Network: $nwclean"
35
36noticount=$(notify show | wc -l)
37
38printf '%s' "$network$sep$volume$sep$battery$sep$date$sep$time"
39[ "$noticount" = "1" ] && printf '%s' "$sep$(notify show)"
40[ "$noticount" -gt "1" ] && printf '%s' "${sep}Unread items: $noticount"
41printf '\n'

Generated with cgit - Back to sebastiano.tronto.net