Fixed mode notification and refactored mode toggle.

This commit is contained in:
Richard Neumann 2020-04-28 21:54:11 +02:00
parent ffd6978317
commit d46be0bc0b
1 changed files with 9 additions and 17 deletions

View File

@ -67,23 +67,6 @@ def notify_tablet_mode():
return notify_send('Tablet mode.', 'The system is now in tablet mode.')
def toggle_mode(notify=False):
"""Toggles between laptop and tablet mode."""
if systemctl('status', TABLET_MODE_SERVICE):
systemctl('stop', TABLET_MODE_SERVICE, root=True)
systemctl('start', LAPTOP_MODE_SERVICE, root=True)
if notify:
notify_tablet_mode()
else:
systemctl('stop', LAPTOP_MODE_SERVICE, root=True)
systemctl('start', TABLET_MODE_SERVICE, root=True)
if notify:
notify_laptop_mode()
def default_mode(notify=False):
"""Restores all blocked input devices."""
@ -114,6 +97,15 @@ def tablet_mode(notify=False):
notify_tablet_mode()
def toggle_mode(notify=False):
"""Toggles between laptop and tablet mode."""
if systemctl('status', TABLET_MODE_SERVICE):
laptop_mode(notify=notify)
else:
tablet_mode(notify=notify)
def main():
"""Runs the main program."""