3 ##########################################################################
4 # Copyright (C) 2009 by Sebastian Goth #
7 # This program is free software; you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation; either version 2 of the License, or #
10 # (at your option) version 3. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program; if not, write to the #
19 # Free Software Foundation, Inc., #
20 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
21 ##########################################################################
23 # Simple script to read metadata from mpris compatible mediaplayers via dbus.
28 # The script fills all fields exported by the player's dbusinterface.
29 # They are defined here: http://wiki.xmms2.xmms.se/wiki/MPRIS_Metadata
31 # To see which fields are actually available from your player,
32 # call something like this from a terminal:
34 # qdbus org.mpris.amarok /Player GetMetadata
36 # qdbus org.mpris.vlc /Player GetMetadata
39 # Every field is available in the data hash 'd' via
41 # To edit the output just change the marked line accordingly.
47 print STDERR "Usage: $0 playername\n";
51 die "Please don't use any special characters in playername." if($ARGV[0] =~ /[^\w\d_-]/);
53 open(IN,"qdbus org.mpris.".$ARGV[0]." /Player GetMetadata|") or die "Couldn't get dbus result.";
55 $d{$1} = $2 if(/^([^:]+):\s+([^\n]+)/);
61 ## change the following line to fit your needs ##
62 print "/me is listening to ".$d{"title"}." by ".$d{"artist"};
63 #################################################