20 January 2008

Manipulating amarok remotely using dcop and ssh

Following my friend Ian's recommendation, I moved all of my music onto an amarok installation a couple of years back. Great program, great features, simple to use, nicer for multi-user installations since the database can be shared, able to have automagic playlists like what-haven't-I-listened-to-in-awhile, etc. I can't recommend it highly enough.

Often, I play music from our desktop but work on my laptop. With purely random playlists, two problems arise when listening remotely:

  1. Ack! That's horrible. Next song, please.
  2. What song is this exactly?

Amarok provides an dcop interface that allows CLI access to lots of information. If your remote SSH shell isn't part of the same dcop session (not likely), you need an extra bit of magic to use it.

In my setup, I can answer those two problems with these commands:

  1. dcop --user `whoami` --all-sessions amarok player next
  2. dcop --user `whoami` --all-sessions amarok player nowPlaying
and can setup a remote 'tail' with a fancy one-liner like: while echo -n; do for info in path year artist album track title rating sampleRate score labels trackPlayCounter; do echo -en "${info}:\t"; dcop --user `whoami` --all-sessions amarok player ${info}; done; sleep 10; clear; done where the --all-sessions option solves the different-dcop-session problem and --user `whoami` is required alongside it.

No comments:

Subscribe Subscribe to The Return of Agent Zlerich