| xss (version 2.1) | index /usr/local/lib/python2.2/site-packages/xss/__init__.py |
Python interface to XScreenSaver information
PyXSS is a Pythonic interface to the XScreenSaverInfo struct. It can
tell you the following bits of information (and a bit more):
- Current X idle time in milliseconds
- Whether the screensaver is currently on, off, or disabled
- How many milliseconds the screensaver has been on for, or how many it
will take for it to be activated.
It cannot actually activate or deactivate the screensaver.
(You can do that by typing 'xset s on' and then 'xset s [time]' where time
is the time in seconds that the screensaver should activate in.
Note that this module is not an interface to JWZ's fine screensaver
package, but the extension in XFree86 instead.
Example
=======
>>> import xss
>>> info = xss.get_info()
>>> print info.idle
10
>>> print info.state
0
>>> print info.state == xss.ScreenSaverDisabled
0
>>> print info.state == xss.ScreenSaverOff
1
xss.get_info() returns an xss.XScreenSaverInfo object. The object is
the SWIGged version of this struct:
typedef struct {
Window window; /* screen saver window - may not exist */
int state; /* ScreenSaverOff, ScreenSaverOn, ScreenSaverDisabled*/
int kind; /* ScreenSaverBlanked, ...Internal, ...External */
unsigned long til_or_since; /* time til or since screen saver */
unsigned long idle; /* total time since last user input */
unsigned long eventMask; /* currently selected events for this client */
} XScreenSaverInfo;
The window attribute will be useless. For state and kind, you can test the
values against their named values
(i.e. "print info.state == xss.ScreenSaverOff")
As of version 2.1, we now include IdleTracker and XSSTracker, which are
higher level interfaces. Both keep track of the current idle time and tell
you whether the user became idle or unidle since the last poll, when the
next poll should take place, and the current idle time in milliseconds.
IdleTracker is based on some threshold for idle time, while XSSTracker
announces that the user is idle when the screensaver activates. An example
poller can be found at the end of this file (xss/__init__.py).
| Package Contents | ||||||
| ||||||
| Classes | ||||||||||||||||||
| ||||||||||||||||||
| Functions | ||
| ||
| Data | ||
| ScreenSaverBlanked = 0 ScreenSaverCycle = 2 ScreenSaverDisabled = 3 ScreenSaverExternal = 2 ScreenSaverInternal = 1 ScreenSaverOff = 0 ScreenSaverOn = 1 __author__ = 'David McClosky (dmcc@bigaterisk.com)' __credits__ = 'Made with help from Drew Perttula (drewp@bigasterisk.com)' __file__ = '/usr/local/lib/python2.2/site-packages/xss/__init__.pyc' __name__ = 'xss' __path__ = ['/usr/local/lib/python2.2/site-packages/xss'] __version__ = '2.1' cvar = <Global variables> | ||
| Author | ||
| David McClosky (dmcc@bigaterisk.com) | ||
| Credits | ||
| Made with help from Drew Perttula (drewp@bigasterisk.com) | ||