diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-05-06 08:30:49 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-05-06 08:30:49 +0200 |
| commit | 60052659b98832c78c902e4f27ecee2663d8e913 (patch) | |
| tree | 9efc1388569c43456557aa1975b4bec99bf06c94 /scripts/status-openbsd | |
| parent | 10e16c2fb2266bb2b46ec7ea64d721de0c29a0d9 (diff) | |
| download | config-60052659b98832c78c902e4f27ecee2663d8e913.tar.gz config-60052659b98832c78c902e4f27ecee2663d8e913.zip | |
Added scripts
Diffstat (limited to 'scripts/status-openbsd')
| -rwxr-xr-x | scripts/status-openbsd | 26 |
1 files changed, 26 insertions, 0 deletions
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 | |||
| 10 | sep=${1:-" | "} | ||
| 11 | |||
| 12 | time=$(date +"%H:%M") | ||
| 13 | date=$(date +"%d %b") | ||
| 14 | battery="$(apm | grep -o '[^ ]*%')" | ||
| 15 | ifconfig="$(ifconfig athn0)" | ||
| 16 | network="$(echo "$ifconfig" | grep status | sed 's/.*status: //')" | ||
| 17 | if [ "$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 | ||
| 23 | fi | ||
| 24 | network="$(printf "%.20s" "$nwid")" # Make it shorter | ||
| 25 | |||
| 26 | echo "$network$sep$battery$sep$date$sep$time" | ||
