face detection resets idle time and deactivates ss
[ozzloy@gmail.com/oble] / gss-poke.py
CommitLineData
f2c83133 1#! /usr/bin/env python
2#inhibit then uninhibit gnome-screensaver. this is a kludge for
3#SimulateUserActivity
4#Copyright 2010 Daniel Watson
5'''
6 use a camera to prevent screensaver
7 Copyright (C) 2009 daniel watson, ozzloy@gmail.com
8
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21'''
22'''
23 This file is part of oble.
24
25 oble is free software: you can redistribute it and/or modify
26 it under the terms of the GNU General Public License as published by
27 the Free Software Foundation, either version 3 of the License, or
28 (at your option) any later version.
29
30 oble is distributed in the hope that it will be useful,
31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 GNU General Public License for more details.
34
35 You should have received a copy of the GNU General Public License
36 along with oble. If not, see <http://www.gnu.org/licenses/>.
37
38'''
39
40
41
42import dbus
43import dbus.glib
44import sys
45import time
46
47def inhibit():
48 try:
49 bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
50 devobj = bus.get_object('org.gnome.ScreenSaver', '/org/gnome/ScreenSaver')
51 dev = dbus.Interface(devobj, "org.gnome.ScreenSaver")
52 cookie = dev.Inhibit('gss-poke', 'SimulateUserActivity kludge')
53 print "gnome screensaver inhibited."
54 return (dev, cookie)
55 except Exception, e:
56 print "could not send the dbus Inhibit signal: %s" % e
57 return (False, False)
58
59def uninhibit(dev, cookie):
60 try:
61 dev.UnInhibit(cookie)
62 print "gnome screensaver enabled."
63 return(True)
64 except Exception, e:
65 print "could not send the dbus UnInhibit signal: %s" % e
66 return (False)
67
68if __name__ == '__main__':
69 (dev, cookie) = inhibit()
70 time.sleep(0.1)
71 uninhibit(dev, cookie)
72 sys.exit(0)