This repository has been archived on 2022-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
zeropod/main.py

49 lines
1.2 KiB
Python

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()