#!/bin/bash # Usage: ${execp ~/.conky-rhythmbox.sh} # rhythmbox off: all fields empty # not playing: title is "not playing", others empty # normal song/podcast: all fields filled in # internet radio: title and elapsed filled in, duration unknown, others empty # get values TITLE=`rhythmbox-client --no-start --print-playing-format "%tt"` ARTIST=`rhythmbox-client --no-start --print-playing-format "%ta"` ALBUM=`rhythmbox-client --no-start --print-playing-format "%at"` ELAPSED=`rhythmbox-client --no-start --print-playing-format "%te"` DURATION=`rhythmbox-client --no-start --print-playing-format "%td"` # cut them off if they're too long CUTOFF=32 if [ ${#TITLE} -gt $CUTOFF ]; then TITLE=`echo "$TITLE" | cut -c-$CUTOFF` TITLE="${TITLE}..." fi if [ ${#ARTIST} -gt $CUTOFF ]; then ARTIST=`echo "$ARTIST" | cut -c-$CUTOFF` ARTIST="${ARTIST}..." fi if [ ${#ALBUM} -gt $CUTOFF ]; then ALBUM=`echo "$ALBUM" | cut -c-$CUTOFF` ALBUM="${ALBUM}..." fi # when using gapless playback (crossfade = 0), elapsed time may sometimes equal "Unknown". let's fix that. if [ "$ELAPSED" = "Unknown" ]; then ELAPSED="0:00" fi # now the real work if [ -z "$TITLE" ]; then # rhythmbox is off echo "\$alignc Not playing" else # rythmbox is on echo "\$alignc $TITLE" # title is always filled in, it might be "Not playing" if [ "$TITLE" != "Not playing" ]; then # rhythmbox is playing something if [ -n "$ARTIST" ]; then # show artist if not empty echo "\$alignc $ARTIST" fi if [ -n "$ALBUM" ] && [ "$ALBUM" != "Unknown" ]; then # show album if not empty/unknown echo "\$alignc $ALBUM" fi if [ "$DURATION" = "Unknown" ]; then echo "\$alignc $ELAPSED" else echo " $ELAPSED\${alignr}$DURATION" fi fi fi