File: mpris

package info (click to toggle)
quassel 1:0.13.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 25,640 kB
  • sloc: cpp: 66,953; perl: 15,837; ansic: 4,418; sql: 1,225; sh: 328; xml: 263; python: 224; makefile: 24
file content (66 lines) | stat: -rwxr-xr-x 2,589 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl

##########################################################################
#  Copyright (C) 2009 by Sebastian Goth                                  #
#   seezer@roath.org                                                     #
#                                                                        #
#  This program is free software; you can redistribute it and/or modify  #
#  it under the terms of the GNU General Public License as published by  #
#  the Free Software Foundation; either version 2 of the License, or     #
#  (at your option) version 3.                                           #
#                                                                        #
#  This program is distributed in the hope that it will be useful,       #
#  but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#  GNU General Public License for more details.                          #
#                                                                        #
#  You should have received a copy of the GNU General Public License     #
#  along with this program; if not, write to the                         #
#  Free Software Foundation, Inc.,                                       #
#  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
##########################################################################

# Simple script to read metadata from mpris compatible mediaplayers via dbus.
#
# Run it like this:
# mpris amarok
#
# The script fills all fields exported by the player's dbusinterface.
# They are defined here: http://wiki.xmms2.xmms.se/wiki/MPRIS_Metadata
#
# To see which fields are actually available from your player,
# call something like this from a terminal:
#
# qdbus org.mpris.amarok /Player GetMetadata
# or
# qdbus org.mpris.vlc /Player GetMetadata
# etc.
# 
# Every field is available in the data hash 'd' via
# $d{"NAME_OF_FIELD"}
# To edit the output just change the marked line accordingly.

use strict;
my %d;

if($#ARGV < 0) {
 print STDERR "Usage: $0 playername\n";
 exit 1;
}

die "Please don't use any special characters in playername." if($ARGV[0] =~ /[^\w\d_-]/);

open(IN,"qdbus org.mpris.".$ARGV[0]." /Player GetMetadata|") or die "Couldn't get dbus result.";
while(<IN>) {
	$d{$1} = $2 if(/^([^:]+):\s+([^\n]+)/);
}
close IN;

if(keys(%d)) {

## change the following line to fit your needs ##
print "/me is listening to ".$d{"title"}." by ".$d{"artist"};
#################################################

print "\n";
}