def show_paused(self): # Debug info if self.debug == True: print "Show paused..." # Get Spotify tray icon coordinates coords = self.get_tray_coords() # Configure notification hints if coords['x'] > 0: hints = { 'x': coords['x'], 'y': coords['y'] } else: hints = {} # Get interface for call notification daemon proxy = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications') interface = Interface(proxy, dbus_interface='org.freedesktop.Notifications') # Closes active notification if self.nid != False: if self.debug == True: print "Closing existing notification..." interface.CloseNotification(self.nid) # Shows notification self.nid = interface.Notify('Spotify', 0, '/usr/share/pixmaps/spotify.png', 'Spotify', self.translate('playback_paused'), [], hints, self.timeout)
def show_playing(self, track = False, interactive = True): # Debug info if self.debug == True and interactive == True: print "Show track data interactively..." elif self.debug == True: print "Show track data..." # Define actions in notification if interactive == True: actions = [ '2', self.translate('action_next') ] else: actions = [] # If track not specified in parameter, read from D-Bus if not track: track = self.get_metadata() # If there's a song playing if track: # Get Spotify tray icon coordinates coords = self.get_tray_coords() # Configure notification hints if coords['x'] > 0: hints = { 'x': coords['x'], 'y': coords['y'] } else: hints = {} # Generate notification content text = self.translate('detail_by') + ' <i>' + self.get_info(track, 'artist') text = text + '</i> ' + self.translate('detail_album') + ' <i>' + self.get_info(track, 'album') + '</i>' text = text.replace('&', '&') # Get interface for call notification daemon proxy = self.bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications') interface = Interface(proxy, dbus_interface='org.freedesktop.Notifications') # Closes active notification if self.nid != False: if self.debug == True: print "Closing existing notification..." interface.CloseNotification(self.nid) # Shows notification self.nid = interface.Notify('Spotify', 0, self.get_cover(), self.get_info(track, 'title'), text, actions, hints, self.timeout) # Connects to actions signals if self.nid > 0: if interactive == True: interface.connect_to_signal('ActionInvoked', self.action_listener) interface.connect_to_signal('NotificationClosed', self.action_dismisser) gobject.threads_init() gobject.timeout_add(self.timeout * 10, self.action_listener) return self.nid
def close_notification(self): # Get interface for call notification daemon proxy = self.bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications') interface = Interface(proxy, dbus_interface='org.freedesktop.Notifications') # Closes active notification if self.nid != False: if self.debug == True: print "Closing existing notification..." interface.CloseNotification(self.nid)