From 985f48c6521c2f88ff08451a09da19085fc1fe7b Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 19 Jul 2025 00:49:59 -0400 Subject: [PATCH] Updated screen toggling stuff to be more generic. --- usr/local/bin/game_launcher.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/usr/local/bin/game_launcher.py b/usr/local/bin/game_launcher.py index 9553796..e9e759a 100755 --- a/usr/local/bin/game_launcher.py +++ b/usr/local/bin/game_launcher.py @@ -284,18 +284,26 @@ class VoicedMenu: self.draw_menu() def toggle_screen(self, screenType): - """Toggle between HDMI screen and headless mode""" - # Remove any existing configuration + """Toggle between screen output and headless mode""" try: - os.system("sudo rm /etc/X11/xorg.conf.d/10-*.conf") - - # Copy the appropriate configuration file + # Platform-specific handling + is_x86 = platform.machine() == "x86_64" + if screenType == "headless": + if is_x86: + # On x86, remove all 10-* files for best compatibility + os.system("sudo rm -f /etc/X11/xorg.conf.d/10-*.conf") + else: + # On Pi, only remove non-essential files, preserve fbdev + os.system("sudo rm -f /etc/X11/xorg.conf.d/10-screen.conf") + configFile = "/home/stormux/.local/files/10-headless.conf" - message = "HDMI Screen disabled." + message = "Screen disabled." else: + # For enabling screen, remove any existing configuration first + os.system("sudo rm -f /etc/X11/xorg.conf.d/10-*.conf") configFile = "/home/stormux/.local/files/10-screen.conf" - message = "HDMI Screen enabled." + message = "Screen enabled." # Copy the configuration file os.system(f"sudo cp {configFile} /etc/X11/xorg.conf.d/") @@ -958,8 +966,8 @@ if __name__ == "__main__": menu.add_item("System", "Install System to Hard Drive", "GAME='Install to Disk' /home/stormux/.clirc") menu.add_item("System", "Internet Configuration", "GAME=\"Network Configuration\" /home/stormux/.clirc") - menu.add_item("System", "Use HDMI Screen", lambda: menu.toggle_screen("screen")) - menu.add_item("System", "Disable HDMI Screen", lambda: menu.toggle_screen("headless")) + menu.add_item("System", "Enable Screen", lambda: menu.toggle_screen("screen")) + menu.add_item("System", "Disable Screen", lambda: menu.toggle_screen("headless")) menu.add_item("System", "Set System Default Speech Rate", "/usr/local/bin/speechd_rate.py") menu.add_item("System", "Set Default Voice", "/usr/local/bin/set-voice.py") menu.add_item("System", "Set Timezone", "GAME='Set Timezone' /home/stormux/.clirc")