sbar (948B)
1 #!/bin/sh 2 3 swidth=$(wattr w `lsw -r`) 4 geom="${swidth}x20" 5 6 BG="#202a31" 7 FG="#abb0c0" 8 9 LEMON_FLAVOR="-dbg $geom -B${BG} -F${FG}" 10 11 workspaces(){ 12 printf '%%{R} %s %%{R}' "$(cat /tmp/workspaces/curr)" 13 } 14 15 winname() { 16 xprop -id "$(pfw)" | grep WM_CLASS | cut -d '"' -f 2 17 } 18 19 20 clock() { 21 printf 'TIME %%{R} %s %%{R}' "$(date +%H:%M)" 22 } 23 24 bat(){ 25 case $(uname -s) in 26 "Linux") 27 printf 'BAT %%{R} %s %%{R}' "$(cat /sys/class/power_supply/BAT1/capacity)%" 28 ;; 29 30 "OpenBSD") 31 esac 32 } 33 34 35 todo() { 36 printf 'TODO %%{R} %d %%{R}' $(<$HOME/rules/todo wc -l) 37 } 38 39 40 sound() { 41 case $(uname -s) in 42 "Linux") 43 ;; 44 45 "OpenBSD") 46 sndioctl output.level | awk -F '=' '{ printf "%.2f%%\n", $2 * 100 }' 47 esac 48 } 49 50 while :; do 51 BUF= 52 BUF="$(workspaces)" 53 BUF="${BUF} %{c}$(winname)" 54 BUF="${BUF}%{r}$(todo) $(sound) $(clock) $(bat)" 55 echo $BUF 56 sleep 1 57 done | lemonbar $LEMON_FLAVOR