import os import signal from icecream import ic from time import sleep from menu import Menu, MenuItem, MenuType from cinput import ControlInput from graphics import Graphics menu_config = [ MenuItem("Information", MenuType.PLUGIN, {"plugin": "info"}), MenuItem("Apps", MenuType.SUB_MENU, {"sub_menu": [ MenuItem("Chess", MenuType.PLUGIN, {"plugin": "chess"}), ]}), MenuItem("Reboot", MenuType.EXIT_CMD, {"command": "sudo reboot"}), MenuItem("Shutdown", MenuType.EXIT_CMD, {"command": "sudo shutdown now"})] cinput = ControlInput() graphics = Graphics() menu = Menu(menu_config, cinput, graphics) def program_exit(*_): graphics.clear() graphics.show() os._exit(0) signal.signal(signal.SIGINT, program_exit) signal.signal(signal.SIGTERM, program_exit) try: while True: item = menu.get_selection() if item.menu_type == MenuType.EXIT_CMD: os.system(item.data["command"]) program_exit() except Exception as e: ic(e) program_exit()