diff --git a/App/Dashboard/DashboardView.swift b/App/Dashboard/DashboardView.swift index 3731ab6..45deb2e 100644 --- a/App/Dashboard/DashboardView.swift +++ b/App/Dashboard/DashboardView.swift @@ -67,6 +67,11 @@ struct DashboardView: View { } .onDisappear { Dashboard.didClose() } .onOpenURL { url in + // scripts/measure-cpu.sh closes the window of the build it measures this way. + if Setup.staysInBackground, url.lastPathComponent == "close" { + Dashboard.close() + return + } // chargectl://dashboard/ if let target = DashboardPage(rawValue: url.lastPathComponent) { page = target } // Measuring in the background: keep the window above whatever the user brought forward. diff --git a/scripts/measure-cpu.sh b/scripts/measure-cpu.sh index 7e97276..2a5fc51 100755 --- a/scripts/measure-cpu.sh +++ b/scripts/measure-cpu.sh @@ -92,9 +92,10 @@ show overview sleep 4 read -r app_cpu server_cpu < <(measure) row "overview, in background" "$app_cpu" "$server_cpu" -# Quitting from outside only closes the dashboard; the app stays in the menu bar. AppleScript -# reports that as a cancelled quit. -osascript -e "tell application \"$app\" to quit" >/dev/null 2>&1 || true +# Closes this app's window with a link only --background builds answer. Never quit it with +# AppleScript: that finds apps by bundle identifier and also quits an installed Chargectl, which +# stops its helper and hands charging back to macOS. +show close sleep 4 read -r app_cpu server_cpu < <(measure) row "window closed" "$app_cpu" "$server_cpu"