Debian Codegraph @

scripts/dogtail-logout

raw
1 # -*- coding: utf-8 -*-
2 from __future__ import absolute_import, division, print_function, unicode_literals
3
4 import getpass
5 from time import sleep
6 from dogtail.tree import root
7 from dogtail.logging import debug_message
8
9
10 debug_message(message="Executing dogtail-logout script.")
11
12
13 debug_message(message="Saving the gnome-shell Accessibility object.")
14 shell = root.application("gnome-shell")
15
16 debug_message(message="Open the System menu.")
17 shell.child(name="System", roleName="menu").click()
18
19 debug_message(message="Open the user menu.")
20 shell.child(name=getpass.getuser(), roleName="label").click()
21
22 debug_message(message="Click Log Out.")
23 shell.child(name="Log Out", roleName="label").click()
24
25 debug_message(message="Confirm logging out.")
26 shell.findChild(lambda x: x.name == "Log Out" and x.roleName in ("button", "push button")).click()
27
28
29 debug_message(message="Some sleep that wont get to the end as the session will end.")
30 sleep(5)