I've been trying to write a shell script that will interface with cmus and then notify me of the track info using notify-send. Right now it is not working, mainly because xargs does not seem to pass 2 arguments to notify-send. It only sends one and I cannot figure out why. I've done everything I can think of with sed to get the right output but it doesn't work. Also, if I use notify-send with two arguments, it works, so I don't think it's a problem with notify-send.
The output of cmus-remote -Q is:
status paused
file /home/dennis/music/Coheed And Cambria/GOODAP~1/05 Crossing the Frame.mp3
duration 207
position 120
tag artist Coheed & Cambria
tag album Good Apollo I'm Burning Star IV Volume One: From Fear Through the Eyes of Madness
tag title Crossing the Frame
tag date 2005
tag genre Rock
tag tracknumber 5
tag albumartist Coheed & Cambria
set aaa_mode all
set continue true
set play_library true
set play_sorted false
set replaygain disabled
set replaygain_limit true
set replaygain_preamp 6.000000
set repeat false
set repeat_current false
set shuffle true
set softvol false
set vol_left 100
set vol_right 100
My code is terrible. I'm just starting to learn shell scripting so sorry about that.
#!/bin/sh
#
# notify of song playing
info="$(cmus-remote -Q)"
title="`echo "$info" | grep 'tag title' | sed "s/'//g" | sed 's/tag title \(.*\)/'\''\1'\''/g'`"
artist="`echo "$info" | grep 'tag artist' | sed "s/'//g" | sed 's/tag artist \(.*\)/ '\''\1/g'`"
album="`echo "$info" | grep 'tag album ' | sed "s/'//g" | sed 's/tag album \(.*\)/ \1'\''/g'`"
stupid="${title}${artist}$album"
echo "$stupid" | xargs notify-send