snakeware

Python-based Linux distro for x86-64 and RPi
git clone git://squid-tech.com/snakeware.git
Log | Files | Refs | README

commit cdb3d256131659dfeedfd2d2937d6166b0dc0ab3
parent 746331a07f8184d3d52f9cd43d4ce62b799990a0
Author: Josh Moore <jxm5210@g.rit.edu>
Date:   Sat, 30 May 2020 23:00:40 -0400

Merge pull request #23 from karx1/shutdown

Shutdown
Diffstat:
M.gitignore | 3+++
Asnakewm/apps/leave/Reboot/__init__.py | 11+++++++++++
Asnakewm/apps/leave/Reboot/confirm.py | 24++++++++++++++++++++++++
Asnakewm/apps/leave/Shutdown/__init__.py | 11+++++++++++
Asnakewm/apps/leave/Shutdown/confirm.py | 24++++++++++++++++++++++++
5 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1 +1,3 @@ *.swp +venv/ +.idea/+ \ No newline at end of file diff --git a/snakewm/apps/leave/Reboot/__init__.py b/snakewm/apps/leave/Reboot/__init__.py @@ -0,0 +1,11 @@ +from .confirm import RebootConfirmationDialog + + +def load(manager, params): + """Launch reboot confirmation dialog""" + pos = (100, 100) + + if params and len(params) > 0: + pos = params[0] + + RebootConfirmationDialog(pos, manager) diff --git a/snakewm/apps/leave/Reboot/confirm.py b/snakewm/apps/leave/Reboot/confirm.py @@ -0,0 +1,24 @@ +import pygame +import pygame_gui +import os + + +class RebootConfirmationDialog(pygame_gui.windows.UIConfirmationDialog): + def __init__(self, pos, manager): + super().__init__( + pygame.Rect(pos, (300, 160)), + manager=manager, + window_title="Reboot?", + action_long_desc="Are you sure you want to reboot the system?", + action_short_name="Reboot", + blocking=False, + object_id="#reboot" + ) + + def process_event(self, event): + super().process_event(event) + + if event.type == pygame_gui.UI_CONFIRMATION_DIALOG_CONFIRMED: + os.system("/sbin/reboot -f") + return True + return False diff --git a/snakewm/apps/leave/Shutdown/__init__.py b/snakewm/apps/leave/Shutdown/__init__.py @@ -0,0 +1,11 @@ +from .confirm import ShutdownConfirmationDialog + + +def load(manager, params): + """Launch shutdown confirmation manager""" + pos = (100, 100) + + if params and len(params) > 0: + pos = params[0] + + ShutdownConfirmationDialog(pos, manager) diff --git a/snakewm/apps/leave/Shutdown/confirm.py b/snakewm/apps/leave/Shutdown/confirm.py @@ -0,0 +1,24 @@ +import pygame +import pygame_gui +import os + + +class ShutdownConfirmationDialog(pygame_gui.windows.UIConfirmationDialog): + def __init__(self, pos, manager): + super().__init__( + pygame.Rect(pos, (300, 160)), + manager=manager, + window_title="Shutdown?", + action_long_desc="Are you sure you want to shut down the system?", + action_short_name="Shut down", + blocking=False, + object_id="#shutdown" + ) + + def process_event(self, event): + super().process_event(event) + + if event.type == pygame_gui.UI_CONFIRMATION_DIALOG_CONFIRMED: + os.system("/sbin/poweroff -f") + return True + return False