xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #492: watch_PrepareForSleep.py

File watch_PrepareForSleep.py, 689 bytes (added by Antoine Martin, 7 years ago)

dbus script using the new login1 interface

Line 
1#!/usr/bin/env python
2
3from datetime import datetime
4import dbus
5import gobject
6from dbus.mainloop.glib import DBusGMainLoop
7
8def handle_sleep(*args):
9    print "%s    PrepareForSleep%s" % (datetime.now().ctime(), args)
10
11DBusGMainLoop(set_as_default=True)     # integrate into gobject main loop
12bus = dbus.SystemBus()                 # connect to system wide dbus
13bus.add_signal_receiver(               # define the signal to listen to
14    handle_sleep,                      # callback function
15    'PrepareForSleep',                 # signal name
16    'org.freedesktop.login1.Manager',  # interface
17    'org.freedesktop.login1'           # bus name
18)
19
20loop = gobject.MainLoop()
21loop.run()