https://github.com/b-ryan/py-screen-events
A python library to detect when your screen turns on or off.
https://github.com/b-ryan/py-screen-events
Last synced: over 1 year ago
JSON representation
A python library to detect when your screen turns on or off.
- Host: GitHub
- URL: https://github.com/b-ryan/py-screen-events
- Owner: b-ryan
- License: mit
- Created: 2014-10-15T00:54:44.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-09T22:27:54.000Z (almost 11 years ago)
- Last Synced: 2025-01-10T20:53:01.351Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 176 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
py-screen-events
================
A python library to detect when your screen goes blank or wakes up.
Has been tested on Ubuntu 14.04 and OS X Yosemite using Python 2.7.6.
Usage
=====
Have a callback function triggered whenever the screen is locked or turns off:
```python
from screen_events import ScreenState, event_loop
def callback(state):
if state == ScreenState.ON:
print "the screen was unlocked or it turned back on"
elif state == ScreenState.OFF:
print "the screen was locked or it turned off"
else:
print "this will never happen"
event_loop(callback)
```
To get the current state of the screen:
```python
from screen_events import screen_state
print screen_state()
```
Relevant links
==============
Bug report for GetActive (dbus org.gnome.ScreenSaver) changing in trusty:
https://bugs.launchpad.net/unity/+bug/1342152
Python dbus examples (particularly interesting is INTROSPECTIVE_IFACE):
http://en.wikibooks.org/wiki/Python_Programming/Dbus
Docs for org.gnome.ScreenSaver:
https://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html#gs-method-GetActive