status-openbsd (693B)
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"