[Rhythmbox-devel] Session Presence Plugin
- From: Alex Jones <alex weej com>
- To: rhythmbox-devel gnome org
- Subject: [Rhythmbox-devel] Session Presence Plugin
- Date: Wed, 28 Mar 2007 20:16:41 +0100
Hi all
I've coded a plugin to pay attention to changes in desktop session
presence (i.e. "is the user here or not?"), and pause/resume Rhythmbox
as appropriate.
I was wondering if there was a better way to deal with the logic of
having something automatically pause Rhythmbox than what I've done with
a "paused by us" flag. I could also monitor playing state changes to
decide if someone is overriding it, but I don't know if I'm just barking
up the wrong tree by doing it this way. I'd think it would be nicer to
somehow impose a state of suspension on RB internally, rather than just
automatically hitting play and pause.
Cheers!
--
Alex Jones
http://alex.weej.com/
import rb
import gobject
import dbus
import dbus.glib
class SessionPresenceManagerPlugin(rb.Plugin):
def __init__(self):
rb.Plugin.__init__(self)
def activate(self, shell):
self.shell = shell
self.paused_by_us = False
session_bus = dbus.SessionBus()
session_bus.add_signal_receiver(self.on_status_changed_cb,
signal_name="StatusChanged",
dbus_interface="com.weej.SessionPresenceManager",
named_service=None,
path="/com/weej/SessionPresenceManager")
def deactivate(self, shell):
del self.shell
def on_status_changed_cb(self, status):
player = self.shell.get_player()
if (status == "here" and self.paused_by_us):
player.play()
self.paused_by_us = False
if (status == "not-here" and player.get_playing()):
self.shell.get_player().pause()
self.paused_by_us = True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]