client: Sort network name case-insensitively
[quassel.git] / data / scripts / mpris
1 #!/usr/bin/env perl
2
3 ##########################################################################
4 #  Copyright (C) 2009 by Sebastian Goth                                  #
5 #   seezer@roath.org                                                     #
6 #                                                                        #
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.                                           #
11 #                                                                        #
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.                          #
16 #                                                                        #
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 ##########################################################################
22
23 # Simple script to read metadata from mpris compatible mediaplayers via dbus.
24 #
25 # Run it like this:
26 # mpris amarok
27 #
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
30 #
31 # To see which fields are actually available from your player,
32 # call something like this from a terminal:
33 #
34 # qdbus org.mpris.amarok /Player GetMetadata
35 # or
36 # qdbus org.mpris.vlc /Player GetMetadata
37 # etc.
38
39 # Every field is available in the data hash 'd' via
40 # $d{"NAME_OF_FIELD"}
41 # To edit the output just change the marked line accordingly.
42
43 use strict;
44 my %d;
45
46 if($#ARGV < 0) {
47  print STDERR "Usage: $0 playername\n";
48  exit 1;
49 }
50
51 die "Please don't use any special characters in playername." if($ARGV[0] =~ /[^\w\d_-]/);
52
53 open(IN,"qdbus org.mpris.".$ARGV[0]." /Player GetMetadata|") or die "Couldn't get dbus result.";
54 while(<IN>) {
55         $d{$1} = $2 if(/^([^:]+):\s+([^\n]+)/);
56 }
57 close IN;
58
59 if(keys(%d)) {
60
61 ## change the following line to fit your needs ##
62 print "/me is listening to ".$d{"title"}." by ".$d{"artist"};
63 #################################################
64
65 print "\n";
66 }