# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

import getpass
from time import sleep
from dogtail.tree import root
from dogtail.logging import debug_message


debug_message(message="Executing dogtail-logout script.")


debug_message(message="Saving the gnome-shell Accessibility object.")
shell = root.application("gnome-shell")

debug_message(message="Open the System menu.")
shell.child(name="System", roleName="menu").click()

debug_message(message="Open the user menu.")
shell.child(name=getpass.getuser(), roleName="label").click()

debug_message(message="Click Log Out.")
shell.child(name="Log Out", roleName="label").click()

debug_message(message="Confirm logging out.")
shell.child(name="Log Out", roleName="push button").click()


debug_message(message="Some sleep that wont get to the end as the session will end.")
sleep(5)
