blob: 638205330d072b196a92483de3c00f1b8cdbce58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/bin/sh
# Prints some status info to stdout. Includes:
# - date and time
# - battery
# - wifi (requires ifconfig on OpenBSD)
# Usage: status [separator]
sep=${1:-" | "}
time=$(date +"%H:%M")
date=$(date +"%d %b")
battery="$(apm | grep -o '[^ ]*%')"
ifconfig="$(ifconfig athn0)"
network="$(echo "$ifconfig" | grep status | sed 's/.*status: //')"
if [ "$network" = "active" ]; then
nwid="$(echo "$ifconfig" | grep nwid | sed 's/.*nwid //;s/ chan.*//')"
if [ -z "$nwid" ]; then
nwid="$(echo "$ifconfig" | grep ieee80211 | \
sed 's/.*ieee80211: join //' | sed 's/ chan.*//')"
fi
fi
network="$(printf "%.20s" "$nwid")" # Make it shorter
echo "$network$sep$battery$sep$date$sep$time"
|