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

View File

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