diff --git a/ks_includes/defaults.conf b/ks_includes/defaults.conf index af596e31..a976535a 100644 --- a/ks_includes/defaults.conf +++ b/ks_includes/defaults.conf @@ -268,6 +268,7 @@ panel: network name: {{ gettext('System') }} icon: info panel: system +enable: {{ moonraker_connected }} [menu __splashscreen settings] name: {{ gettext('Settings') }} diff --git a/panels/menu.py b/panels/menu.py index bbd0a9ab..bb08f4b6 100644 --- a/panels/menu.py +++ b/panels/menu.py @@ -104,6 +104,10 @@ class MenuPanel(ScreenPanel): if enable is False: return False + if enable == "{{ moonraker_connected }}": + logging.info("moonraker is_connected %s", self._screen._ws.is_connected()) + return self._screen._ws.is_connected() + if not self.j2_data: self.j2_data = self._printer.get_printer_status_data() try: diff --git a/panels/splash_screen.py b/panels/splash_screen.py index b2369d45..9045b16f 100644 --- a/panels/splash_screen.py +++ b/panels/splash_screen.py @@ -131,7 +131,21 @@ class SplashScreenPanel(ScreenPanel): def shutdown(self, widget): - os.system("sudo shutdown -P now") + _ = self.lang.gettext + if self._screen._ws.is_connected(): + self._screen._confirm_send_action(widget, + _("Are you sure you wish to shutdown the system?"), + "machine.shutdown") + else: + logging.info("OS Shutdown") + os.system("systemctl poweroff") def restart_system(self, widget): - os.system("sudo reboot now") + _ = self.lang.gettext + if self._screen._ws.is_connected(): + self._screen._confirm_send_action(widget, + _("Are you sure you wish to reboot the system?"), + "machine.reboot") + else: + logging.info("OS Reboot") + os.system("systemctl reboot")