herbstluft - add quodlibit now playing to panel

This commit is contained in:
Felix Van der Jeugt 2015-01-24 23:48:36 +01:00
parent 3878943e26
commit ac4d3c7e65

View File

@ -100,15 +100,35 @@ hc pad $monitor $panel_height
done > >(uniq_linebuffered) & done > >(uniq_linebuffered) &
batteryloop=$! batteryloop=$!
# quodlibet events
while true ; do
status=$(quodlibet --status | cut -d' ' -f1)
case $status in
"playing")
echo -en "music\t^fg(#909090)"
quodlibet --print-playing "<title~album>" | iconv -f utf-8 -t ascii//translit
;;
"paused")
echo -e "music ^fg(#909090)pauzed"
;;
*)
;;
esac
sleep 5 || break
done > >(uniq_linebuffered) &
quodloop=$!
# hc events # hc events
hc --idle hc --idle
kill $timeloop kill $timeloop
kill $batteryloop kill $batteryloop
kill $quodloop
} 2> /dev/null | { } 2> /dev/null | {
IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
visible=true visible=true
date="" date=""
power="" power=""
music=""
windowtitle="" windowtitle=""
while true ; do while true ; do
@ -154,7 +174,7 @@ hc pad $monitor $panel_height
echo -n "$separator" echo -n "$separator"
echo -n "^bg()^fg() ${windowtitle//^/^^}" echo -n "^bg()^fg() ${windowtitle//^/^^}"
# small adjustments # small adjustments
right="$separator^bg() $power $separator $date $separator" right="$music $separator^bg() $power $separator $date $separator"
right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g') right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g')
# get width of right aligned text.. and add some space.. # get width of right aligned text.. and add some space..
width=$($textwidth "$font" "$right_text_only ") width=$($textwidth "$font" "$right_text_only ")
@ -184,6 +204,9 @@ hc pad $monitor $panel_height
power) power)
power="${cmd[@]:1}" power="${cmd[@]:1}"
;; ;;
music)
music="${cmd[@]:1}"
;;
quit_panel) quit_panel)
exit exit
;; ;;