3
# Specto , Unobtrusive event notifier
5
# watch_music_rhythmbox.py
7
# See the AUTHORS file for copyright ownership information
9
# This program is free software; you can redistribute it and/or
10
# modify it under the terms of the GNU General Public
11
# License as published by the Free Software Foundation; either
12
# version 2.1 of the License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
# General Public License for more details.
19
# You should have received a copy of the GNU General Public
20
# License along with this program; if not, write to the
21
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
# Boston, MA 02111-1307, USA.
24
from spectlib.watch import Watch
25
from spectlib.i18n import _
28
type = "Watch_music_rhythmbox"
29
type_desc = _("Rhythmbox")
35
class Watch_music_rhythmbox(Watch):
37
Watch class that will check if a song has changed in rhythmbox.
40
def __init__(self, specto, id, values):
44
self.current_song = ""
45
self.standard_open_command = 'rhythmbox'
46
self.type_desc = type_desc
48
#Init the superclass and set some specto values
49
Watch.__init__(self, specto, id, values, watch_values)
54
# Use the dbus interface we saw in dbus-notify
55
self.dbus_interface = "org.gnome.Rhythmbox.Player"
56
self.dbus_path = "/org/gnome/Rhythmbox/Player"
57
self.dbus_name = "org.gnome.Rhythmbox"
59
self.signals = {"playingUriChanged": self.playingUriChanged}
62
def playingUriChanged(self, uri):
64
info = ["artist", "album", "title", "track-number"]
66
shell = self.get_rhythmbox_interface()
68
data = shell.getSongProperties(uri)
71
metadata[key] = data[key]
73
header = metadata["title"]
74
self.message = "%s - %s\nTrack: %d" %(metadata["artist"],metadata["title"],metadata["track-number"])
75
self.current_song = "%s - %s" % (metadata["artist"], metadata["title"])
78
def get_balloon_text(self):
79
""" create the text for the balloon """
82
def get_gui_info(self):
83
return [(_('Name'), self.name),
84
(_('Last changed'), self.last_changed),
85
(_('Current track'), self.current_song)]
87
def get_rhythmbox_interface(self):
88
rhythmbox_object = self.session_bus.get_object("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Shell")
89
return dbus.Interface(rhythmbox_object, "org.gnome.Rhythmbox.Shell")