lemonade.sh
lemonbar scripts with basic widgets
01:
02:
03: export MPD_HOST=~/.mpd/socket
04: function clock {
05: date +"%H:%M"
06: }
07: function desktop {
08: printf "[%4s]" "$(bspc query -D -d focused --names)"
09: }
10: function layout {
11: xkb-switch -p
12: }
13: function battery {
14: BATTERY=/sys/class/power_supply/BAT0
15: NOW=$(cat $BATTERY/charge_now)
16: FULL=$(cat $BATTERY/charge_full)
17: printf "%02d%%" "$((NOW*100/FULL))"
18: }
19: function now_playing {
20: printf "%.62s" "$(mpc current)"
21: }
22: function clock_update {
23: while true
24: do
25: sleep $(( 60 - $(date +%s) % 60 ))
26: echo clock_update
27: done
28: }
29: function bspwm_update {
30: bspc subscribe desktop
31: }
32: function layout_update {
33: xkb-switch -W
34: }
35: function now_playing_update {
36: while true;
37: do
38: mpc idle player
39: echo
40: done
41: }
42: function bar {
43: echo "%{l}$(desktop) $(now_playing) %{c}$(clock) %{r}$(layout) $(battery)"
44: }
45: function bar_update {
46: bar
47: while read EVENT
48: do
49: bar
50: done < $UPDATE
51: }
52: UPDATE=/tmp/bar_update
53: PID_FILE=/tmp/bar_pids
54:
55: trap "xargs kill < $PID_FILE;rm $PID_FILE" EXIT
56: if [ -e $PID_FILE ]
57: then
58: echo lemonade.sh exists! >&2
59: exit 1
60: fi
61: [ -e $UPDATE ] || mkfifo $UPDATE
62: clock_update > $UPDATE &
63: echo $! > $PID_FILE
64: bspwm_update > $UPDATE &
65: echo $! >> $PID_FILE
66: layout_update > $UPDATE &
67: echo $! >> $PID_FILE
68: now_playing_update > $UPDATE &
69: echo $! >> $PID_FILE
70:
71: bar_update| lemonbar -f monospace:size=9
72: