summaryrefslogtreecommitdiff
path: root/scripts/status
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-05-06 08:30:49 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2026-05-06 08:30:49 +0200
commit60052659b98832c78c902e4f27ecee2663d8e913 (patch)
tree9efc1388569c43456557aa1975b4bec99bf06c94 /scripts/status
parent10e16c2fb2266bb2b46ec7ea64d721de0c29a0d9 (diff)
downloadconfig-60052659b98832c78c902e4f27ecee2663d8e913.tar.gz
config-60052659b98832c78c902e4f27ecee2663d8e913.zip
Added scripts
Diffstat (limited to '')
-rwxr-xr-xscripts/status13
-rwxr-xr-xscripts/status-linux52
-rwxr-xr-xscripts/status-openbsd26
3 files changed, 91 insertions, 0 deletions
diff --git a/scripts/status b/scripts/status
new file mode 100755
index 0000000..66811b0
--- /dev/null
+++ b/scripts/status
@@ -0,0 +1,13 @@
1#!/bin/sh
2
3# Calls one of the system-specific status scripts to display
4# a line of text with some status information (battery, date...)
5
6case "$(uname)" in
7OpenBSD)
8 status-openbsd
9 ;;
10*)
11 status-linux
12 ;;
13esac
diff --git a/scripts/status-linux b/scripts/status-linux
new file mode 100755
index 0000000..a2061d1
--- /dev/null
+++ b/scripts/status-linux
@@ -0,0 +1,52 @@
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 +"%a %d %b")
15
16if [ "$(pulsemixer --get-mute)" -eq 1 ]; then
17 volume="Muted"
18else
19 volume="Vol $(pulsemixer --get-volume | awk '{print $1}')%"
20fi
21
22bat="/sys/class/power_supply/BAT0"
23if [ -d $bat ]; then
24 charge_status="$(cat $bat/status | awk '{print substr ($0, 0, 2)}')"
25 battery="Bat $(cat $bat/capacity)% $charge_status"
26else
27 battery="No battery"
28fi
29
30# NetworkManager has a dreadful command line interface
31# It makes cry every time
32# pls help
33#nwline="$(nmcli device status | head -n 2 | tail -n 1)"
34#nwclean="$(echo "$nwline" | sed 's/ *$//' | sed 's/.* //')"
35#network="Network: $nwclean"
36
37# Thank you iwctl for saving us from this dreadful existence
38network="$(iwctl station wlan0 show | grep 'Connected network' | awk '{print $3}')"
39if [ "$(cat /sys/class/net/eth0/carrier)" = 1 ]; then
40 if [ -z "$network" ]; then
41 network="eth"
42 else
43 network="eth & $network"
44 fi
45fi
46
47noticount=$(notify show | wc -l)
48
49printf '%s' "$network$sep$volume$sep$battery$sep$date$sep$time"
50[ "$noticount" = "1" ] && printf '%s' "$sep$(notify show)"
51[ "$noticount" -gt "1" ] && printf '%s' "${sep}[$noticount]"
52printf '\n'
diff --git a/scripts/status-openbsd b/scripts/status-openbsd
new file mode 100755
index 0000000..6382053
--- /dev/null
+++ b/scripts/status-openbsd
@@ -0,0 +1,26 @@
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")
14battery="$(apm | grep -o '[^ ]*%')"
15ifconfig="$(ifconfig athn0)"
16network="$(echo "$ifconfig" | grep status | sed 's/.*status: //')"
17if [ "$network" = "active" ]; then
18 nwid="$(echo "$ifconfig" | grep nwid | sed 's/.*nwid //;s/ chan.*//')"
19 if [ -z "$nwid" ]; then
20 nwid="$(echo "$ifconfig" | grep ieee80211 | \
21 sed 's/.*ieee80211: join //' | sed 's/ chan.*//')"
22 fi
23fi
24network="$(printf "%.20s" "$nwid")" # Make it shorter
25
26echo "$network$sep$battery$sep$date$sep$time"

Generated with cgit - Back to sebastiano.tronto.net