changed exec cmd to exit cmd

This commit is contained in:
Rudis Muiznieks 2022-04-23 15:44:15 -05:00
parent db2583ad84
commit 47303cdec8
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
2 changed files with 9 additions and 9 deletions

14
main.py
View File

@ -1,5 +1,6 @@
import os import os
import signal import signal
from icecream import ic
from time import sleep from time import sleep
from menu import Menu, MenuItem, MenuType from menu import Menu, MenuItem, MenuType
from cinput import ControlInput from cinput import ControlInput
@ -7,20 +8,20 @@ from graphics import Graphics
menu_config = [ menu_config = [
MenuItem("Information", MenuItem("Information",
MenuType.EXEC_PLUGIN, MenuType.PLUGIN,
{"plugin": "info"}), {"plugin": "info"}),
MenuItem("Apps", MenuItem("Apps",
MenuType.SUB_MENU, MenuType.SUB_MENU,
{"sub_menu": [ {"sub_menu": [
MenuItem("Chess", MenuItem("Chess",
MenuType.EXEC_PLUGIN, MenuType.PLUGIN,
{"plugin": "chess"}), {"plugin": "chess"}),
]}), ]}),
MenuItem("Reboot", MenuItem("Reboot",
MenuType.EXEC_CMD, MenuType.EXIT_CMD,
{"command": "sudo reboot"}), {"command": "sudo reboot"}),
MenuItem("Shutdown", MenuItem("Shutdown",
MenuType.EXEC_CMD, MenuType.EXIT_CMD,
{"command": "sudo shutdown now"})] {"command": "sudo shutdown now"})]
cinput = ControlInput() cinput = ControlInput()
@ -38,10 +39,9 @@ signal.signal(signal.SIGTERM, program_exit)
try: try:
while True: while True:
item = menu.get_selection() item = menu.get_selection()
if item.menu_type == MenuType.EXEC_CMD: if item.menu_type == MenuType.EXIT_CMD:
graphics.clear()
graphics.show()
os.system(item.data["command"]) os.system(item.data["command"])
program_exit()
except Exception as e: except Exception as e:
ic(e) ic(e)
program_exit() program_exit()

View File

@ -5,8 +5,8 @@ from graphics import Graphics
class MenuType(Enum): class MenuType(Enum):
SUB_MENU = auto() SUB_MENU = auto()
EXEC_CMD = auto() EXIT_CMD = auto()
EXEC_PLUGIN = auto() PLUGIN = auto()
@dataclass @dataclass
class MenuItem: class MenuItem: