#!/bin/sh # # dvonik's main.sh for lemonbar # public domain # mem() { used="$(vmstat | awk 'END {printf $3}' | tr -d "M")" all="$(( $(sysctl -n hw.physmem) / 1024 / 1024 ))" echo "$used/$all" } net() { ip="216.21.3.77" ping -s 2 -c 1 "$ip" > "/dev/null" & pid=$! # ip for openbsd wait "$pid"; status="$?" case "$status" in (0) echo "on"; ;; (*) echo "off"; ;; esac } battery() { case "$(apm -b)" in (0) stat="+!"; ;; (1) stat="-!"; ;; (2) stat="--"; ;; (3) stat="++"; ;; esac echo "$(apm -l)% $stat" } bg=111314 fg=b7bbb7 main() { echo "%{F#$fg} $(date "+%F %H:%M %Z") %{r}$(uname -r) [$(uname -v)] $(net) [$(battery)] $(mem) " } while true; do main; sleep 5; done