Shell script, Amarok currently playing.. need some help

Okay this is what I got:

#! /bin/bash
BITRATE=$("qdbus org.kde.amarok /Player GetMetadata | grep bitrate | sed 's/audio-bitrate: //'")
ARTIST=$("qdbus org.kde.amarok /Player GetMetadata | grep artist | sed 's/artist: //'")
ALBUM=$("qdbus org.kde.amarok /Player GetMetadata | grep album | head -n 1 | sed 's/album: //'")
TITLE=$("qdbus org.kde.amarok /Player GetMetadata | grep title | tail -n 1 | sed 's/title: //'")
YEAR=$("qdbus org.kde.amarok /Player GetMetadata | grep year | sed 's/year: //'")
SAMPLERATE=$("qdbus org.kde.amarok /Player GetMetadata | grep audio-samplerate | sed 's/audio-samplerate: //'")

echo -e "np: $ARTIST - $TITLE <$ALBUM ($YEAR)> $FILETYPE @ $BITRATE kbps | $SAMPLERATE hz ] $NOW/$TIME]"

I think the intention should be clear, but in case it’s not.
I want it to echo out the currently playing number with some more info

Interesting, I had not seen qdbus in use before.

However on trying it here, I don’t see Amarok on the dbus list. From some tutes, it appears that this requires Amarok 2. I’m still running Amarok 1.4. Do you have Amarok 2? What do you get when you just run

qdbus

? Is org.kde.amarok in the output? It isn’t on mine.

#! /bin/bash
BITRATE="$(qdbus org.kde.amarok /Player GetMetadata | grep bitrate | sed 's/audio-bitrate: //')"
ARTIST="$(qdbus org.kde.amarok /Player GetMetadata | grep artist | sed 's/artist: //')"
ALBUM="$(qdbus org.kde.amarok /Player GetMetadata | grep album | head -n 1 | sed 's/album: //')"
TITLE="$(qdbus org.kde.amarok /Player GetMetadata | grep title | tail -n 1 | sed 's/title: //')"
YEAR="$(qdbus org.kde.amarok /Player GetMetadata | grep year | sed 's/year: //')"
SAMPLERATE="$(qdbus org.kde.amarok /Player GetMetadata | grep audio-samplerate | sed 's/audio-samplerate: //')"

echo -e "np: $ARTIST - $TITLE <$ALBUM ($YEAR)> $FILETYPE @ $BITRATE kbps | $SAMPLERATE hz ] $NOW/$TIME]" 

Works with Amarok2. You are placing the quotes incorrectly, see correction above

I would also add that you should avoid calling qdbus multiple times. It’s easy enough to save the output in a shell variable and then grep that. Or pipe the output to a script which will do the parsing in one pass.

Thanks for the help, seems like I can’t use it for what I had intended to… kvirc.

Works fine from the shell though.