blob: 83a126a4842a56f048e8faad2b295cfd6379923e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/usr/bin/env python
# Provide DBus service to call xscreensaver
# http://ubuntuforums.org/showthread.php?t=1865593&s=1c7f28c50a3f258e1d3404e41f098a0b&p=11418175#post11418175
import dbus
import dbus.service
import dbus.glib
from gi.repository import GObject
import subprocess
class ScreenDbusObj(dbus.service.Object):
def __init__(self):
session_bus = dbus.SessionBus()
bus_name=dbus.service.BusName("org.freedesktop.ScreenSaver",bus=session_bus)
dbus.service.Object.__init__(self,bus_name, '/org/freedesktop/ScreenSaver')
@dbus.service.method("org.freedesktop.ScreenSaver")
def Lock(self):
subprocess.Popen(['xscreensaver-command', '-lock'])
if __name__ == '__main__':
object=ScreenDbusObj()
GObject.MainLoop().run()
|