/usr/bin/dogtail-detect-session is in python-dogtail 0.9.0-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #! /usr/bin/python
"""
dogtail-detect session
This script checks for some main pieces of a running GNOME session,
specifically gnome-panel and metacity.
It checks to see that the gnome-panel node has at least some child nodes.
For example, the main gnome-panel node by default has two direct descendents:
the top panel, and the bottom panel.
Metacity's existence is also checked. However, metacity currently never has
any child nodes.
If a proper session is running, the scripts exits with a status of 0.
If no session is found, a non-zero exit code is returned.
Author: Zack Cerza <zcerza@redhat.com>
"""
__author__ = "Zack Cerza <zcerza@redhat.com>"
from dogtail.procedural import *
import sys
def GNOME():
"""
"Is an accessibility-enabled GNOME session running?"
"""
running = False
try:
assert focus.desktop
assert focus.desktop.children
focus.application('gnome-panel')
assert focus.application.children
focus.application('metacity')
print focus.application.node
assert focus.application.node
running = True
print "GNOME Session detected."
except AttributeError or AssertionError or FocusError:
print "ERROR: No session found."
return running
def KDE():
"""
"Is an accessibility-enabled KDE session running?"
"""
running = False
return running
def JustSomeApps():
"""
"Is at least one accessibility-enabled application running?"
"""
assert focus.desktop
assert focus.desktop.children
if GNOME() or KDE() or JustSomeApps():
sys.exit()
else:
sys.exit(1)
|