Ticket #547: stop_session_changes.py

File stop_session_changes.py, 802 bytes (added by broder, 11 years ago)
Line 
1#!/usr/bin/python
2
3import dbus
4import gobject
5
6from dbus.mainloop.glib import DBusGMainLoop
7DBusGMainLoop(set_as_default=True)
8
9def stop_session_change(ssid):
10    sessions = dbus.SystemBus().\
11        get_object('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Manager').\
12        GetSessions(dbus_interface='org.freedesktop.ConsoleKit.Manager')
13    if ssid != sessions[0]:
14        dbus.SystemBus().\
15            get_object('org.freedesktop.ConsoleKit', sessions[0]).\
16            Activate(dbus_interface='org.freedesktop.ConsoleKit.Session')
17
18dbus.SystemBus().add_signal_receiver(
19    stop_session_change,
20    'ActiveSessionChanged',
21    'org.freedesktop.ConsoleKit.Seat',
22    'org.freedesktop.ConsoleKit',
23    '/org/freedesktop/ConsoleKit/Seat1'
24    )
25
26loop = gobject.MainLoop()
27loop.run()