def fake_gnome_settings_daemon(): import subprocess, sys, os # FIXME: path will be wrong if we are a submodule # FIXME: Check if fake gnome-settings-daemon has been built path = os.path.join(os.path.dirname(sys.argv[0]), 'gnome-settings-daemon') subprocess.Popen(path, stdout=open('/dev/null', 'w'), stdin=subprocess.PIPE, close_fds=True) # Need to trick this line in /usr/share/acpi-support/policy-funcs: # DBusSend gnome-settings-daemon org.gnome.SettingsDaemon # /org/gnome/SettingsDaemon/Power # org.freedesktop.DBus.Introspectable.Introspect | grep -q 'interface # name="org.gnome.SettingsDaemon.Power"' class FakeGnomeSettings(dbus.service.Object): def __init__(self, bus): bus_name = dbus.service.BusName('org.gnome.SettingsDaemon', bus=bus) dbus.service.Object.__init__(self, bus_name, '/org/gnome/SettingsDaemon/Power') @dbus.service.method(dbus_interface='org.gnome.SettingsDaemon.Power') def FakeGnomeSettingsDaemon(self): pass bus = wmiidbus.get_session_bus() fake = FakeGnomeSettings(bus)
def connect_proxy(): global _purple try: obj = wmiidbus.get_session_bus().get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") _purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") except: _purple = None
def connect_proxy(): global _purple try: obj = wmiidbus.get_session_bus().get_object( "im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") _purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") except: _purple = None
def unload(): global _purple bus = wmiidbus.get_session_bus() bus.remove_signal_receiver(receive_msg, 'ReceivedChatMsg', \ 'im.pidgin.purple.PurpleInterface', None, '/im/pidgin/purple/PurpleObject') bus.remove_signal_receiver(receive_msg, 'ReceivedImMsg', \ 'im.pidgin.purple.PurpleInterface', None, '/im/pidgin/purple/PurpleObject') _purple = None
def unload(): global _notify notify('WARNING: libnotify.py unload called, but it is untested!') # NOTE: I haven't quite figured out how to unregister the service. This # at least drops the well known name (which should happen automatically # when bus_name is no longer referenced), but our connection to the bus # continues to expose the notification interface, and reloading the # plugin will fail to register it bus = wmiidbus.get_session_bus() bus.release_name('org.freedesktop.Notifications') _notify = None
def notify_libnotify(msg, key=None, timeout=1000, **kwargs): import dbus, wmiidbus session_bus = wmiidbus.get_session_bus(start_thread=False) proxy = session_bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications') notifications = dbus.Interface(proxy, 'org.freedesktop.Notifications') id = libnotify_ids.get(key, 0) id = notifications.Notify('purple-DBus-Example-2-libnotify', id, '', '', msg, [], {}, timeout) if key is not None: libnotify_ids[key] = id
def get_spotify_interface(): global _spotify bus = wmiidbus.get_session_bus() if _spotify is not None and bus.name_has_owner(_spotify._named_service): return _spotify # NOTE: Spotify exports two usable interfaces: # org.freedesktop.MediaPlayer2 interface under / # org.mpris.MediaPlayer2.Player interface under /org/mpris/MediaPlayer2 # The latter exports PlaybackStatus, which I don't see an equivelant of # in the former. The former does export volume controls, but they don't # seem to work for me (possibly because I'm using pulseaudio & # bluetooth?) _spotify = bus.get_object('com.spotify.qt', '/org/mpris/MediaPlayer2') return _spotify
def main(): session_bus = wmiidbus.get_session_bus(start_thread=False) add_listeners(session_bus) wmiidbus._main_loop_thread()
def main(): session_bus = wmiidbus.get_session_bus() add_listeners(session_bus)
def main(): global _notify session_bus = wmiidbus.get_session_bus() _notify = libnotify(session_bus)