2 # Copyright 2009 Sebastian Goth seezer@roath.org
4 # Simple script to read metadata from mpris compatible mediaplayers via dbus.
9 # The script fills all fields exported by the player's dbusinterface.
10 # They are defined here: http://wiki.xmms2.xmms.se/wiki/MPRIS_Metadata
12 # To see which fields are actually available from your player,
13 # call something like this from a terminal:
15 # qdbus org.mpris.amarok /Player GetMetadata
17 # qdbus org.mpris.vlc /Player GetMetadata
20 # Every field is available in the data hash 'd' via
22 # To edit the output just change the marked line accordingly.
28 print STDERR "Usage: $0 playername\n";
32 die "Please don't use any special characters in playername." if($ARGV[0] =~ /[^\w\d_-]/);
34 open(IN,"qdbus org.mpris.".$ARGV[0]." /Player GetMetadata|") or die "Couldn't get dbus result.";
36 $d{$1} = $2 if(/^([^:]+):\s+([^\n]+)/);
42 ## change the following line to fit your needs ##
43 print "I'm listening to ".$d{"title"}." by ".$d{"artist"};
44 #################################################