// // SystemHUDDebugger.swift // DynamicIsland // // Debug utility for System HUD functionality // Created by GitHub Copilot on 06/09/25. // import Foundation class SystemHUDDebugger { /// Test system HUD functionality and print status public static func testSystemHUD() { print("\nšŸ” === System HUD Debug Report ===") // Check current OSDUIHelper status let isRunning = SystemOSDManager.isOSDUIHelperRunning() print("šŸ“Š OSDUIHelper Status: \(isRunning ? "āœ… Running" : "āŒ Not running")") // Test disable print("šŸ”‡ Testing disable...") SystemOSDManager.disableSystemHUD() // Wait and check usleep(500000) let isRunningAfterDisable = SystemOSDManager.isOSDUIHelperRunning() print("šŸ“Š After disable: \(isRunningAfterDisable ? "āœ… Running (stopped)" : "āŒ Not running")") // Test enable print("šŸ”Š Testing re-enable...") SystemOSDManager.enableSystemHUD() // Wait and check usleep(1000000) let isRunningAfterEnable = SystemOSDManager.isOSDUIHelperRunning() print("šŸ“Š After re-enable: \(isRunningAfterEnable ? "āœ… Running" : "āŒ Not running")") print("šŸ” === End Debug Report ===\n") if !isRunningAfterEnable { print("āš ļø WARNING: System HUD may not be working properly!") print("šŸ’” Try pressing volume keys to test system HUD functionality") } } /// Force restart OSDUIHelper using multiple methods public static func forceRestartOSDUIHelper() { print("šŸ”„ Force restarting OSDUIHelper...") // Method 1: Kill and kickstart SystemOSDManager.enableSystemHUD() // Method 2: Try launchctl bootstrap (more aggressive) do { let bootstrap = Process() bootstrap.executableURL = URL(fileURLWithPath: "/bin/launchctl") bootstrap.arguments = ["bootstrap", "gui/\(getuid())", "/System/Library/LaunchAgents/com.apple.OSDUIHelper.plist"] try bootstrap.run() bootstrap.waitUntilExit() print("āœ… Bootstrap method completed") } catch { print("āŒ Bootstrap method failed: \(error)") } // Method 3: Try direct service restart do { let restart = Process() restart.executableURL = URL(fileURLWithPath: "/bin/launchctl") restart.arguments = ["restart", "gui/\(getuid())/com.apple.OSDUIHelper"] try restart.run() restart.waitUntilExit() print("āœ… Restart method completed") } catch { print("āŒ Restart method failed: \(error)") } // Check final status usleep(1000000) let finalStatus = SystemOSDManager.isOSDUIHelperRunning() print("šŸ“Š Final OSDUIHelper status: \(finalStatus ? "āœ… Running" : "āŒ Not running")") } }