Wednesday, 20 May 2009

Controlling roommate's music with ssh and dcop

This is rather old one, but I didn't publish it here before.

Both my roommates use Amarok as their music player. I'm OK with music they listen to for 90% of time, but their big, fat playlists hide some real monsters. And they both have a bad habit of leaving the room with Amaroks playing in shuffle mode.

This is why I created two little scripts to pause/change the song without leaving the comfort of my chair.

Here is one, for Paweł (username pavlo) and his widescreen laptop kuandatun (kuandatun it's supposed to mean "wide ass" in Chineese).

ssh kuandatun "/opt/kde3/bin/dcop --all-sessions --user pavlo amarok player $*"

I have kuandatun in /etc/hosts, my .ssh/config knows that it should log in as pavlo to his machine and I have my public key listed in his .ssh/authorized_keys. Now, changing shitty song on his computer is as easy as AmarokPawla next.

The less evil use of this script is getting title, lyrics or artist of currently playing song.

EDIT: this is going to be obsolete soon, when they switch to amarok2, which uses D-Bus instead of DCOP, but it's basically the same trick

1 comment:

Stefanek said...

I respect your genuity :)