diff options
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" | ||
