aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts-2.7/dogtail-logout
blob: c76a4519e083d24323fe851401d70b1419886897 (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
25
26
27
28
#!/usr/bin/python
# Logs out the full gnome session. Be sure to have your documents saved, as running
# may cause loosing the changes, or it may halt the logout process.

from dogtail.tree import *
from dogtail.rawinput import pressKey
from time import sleep
import getpass

# A gnome-shell object
shell = root.application('gnome-shell')
# Click onto a super menu label that we find under the g-s top panel object.
# We need these indexes as g-s a11y support is a wee bit messy.
shell[0][1][2].child(getpass.getuser(), roleName='label').click()
# We can child this all the way down from the app as there's no other Log
# Out... label
shell.child('Log Out...', roleName='label').click()
# This takes care of the 60 second dialog.
# Sometimes a dialog warning about unsaved work in gedit etc. pops out, but that has the same
# push button in which case this will take care of that dialog. If another dialog pops-out
# in the affected application however, that might put the logout process on hold again. Unfortunatelly
# we cannot do anything about that with dotail at that point as a11y registry got disabled already
# by the logout process.
shell[0][1].child(roleName='dialog', recursive=False).child(
    'Log Out', roleName='push button').click()

# Give the session some time to end before we kill it.
sleep(10)