Blob


1 # event-gen
3 This script is the event generator for the bar. The ideas is that
4 it sits waiting for stuff to happen (window focus, date change,
5 music player, ...)
7 #!/usr/bin/env rc
9 . ./lib
11 Kill the player monitor and the date subshell upon exit
13 fn quit {
14 kill $datepid
15 kill $playerpid
16 }
18 fn siguhp { quit }
19 fn sigint { quit }
21 The idea behind `uniq_linebuffered' is to avoid refreshing the bar
22 every tick if the state doesn't change. It doesn't work for some
23 reason however...
25 # XXX: for some reasons this don't work
26 fn uniq_linebuffered {
27 awk '$0 != l { print ; l=$0 ; fflush(); }'
28 }
30 Simulate the tag and play event at the start to force the process
31 to update the tags and music info.
33 echo tag
34 echo play
36 Date event generator:
38 while () {
39 date=`{date +'%H:%M, %Y-%m-%d'}
40 printf 'date\t%s\n' $"date
41 sleep 10 || break
42 } | uniq_linebuffered &
43 datepid=$apid
45 Music player event generator:
47 amused monitor play,next,prev,jump &
48 playerpid=$apid
50 Window manager event generator:
52 hc --idle
54 Kill everything upon exit
56 quit