#!/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)