From 19de24bb527939f23bd1ec46777d2db4612d2689 Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Sun, 27 Sep 2026 15:37:13 -0500 Subject: [PATCH] feat(restart-browsers): quit and reopen browsers nightly The plist was a copy of homebrew-update, label included, so launchd never loaded it as a job of its own. Replace it with an osascript job that runs at 1:00 am and, for each of Chrome, Vivaldi and Floorp that is running, quits it the way Cmd-Q does, waits up to a minute for it to exit, then reopens it in the background. A browser held open by a quit prompt is left alone and logged. --- LaunchAgents/com.user.restart-browsers.plist | 55 +++++++++++++++++--- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/LaunchAgents/com.user.restart-browsers.plist b/LaunchAgents/com.user.restart-browsers.plist index 06aa9da..feee782 100644 --- a/LaunchAgents/com.user.restart-browsers.plist +++ b/LaunchAgents/com.user.restart-browsers.plist @@ -3,24 +3,63 @@ Label - com.user.homebrew-update + com.user.restart-browsers + ProgramArguments - /bin/bash - -c - export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" && brew update && brew upgrade + /usr/bin/osascript + -e + repeat with appName in {"Google Chrome", "Vivaldi", "Floorp"} + -e + set appName to contents of appName + -e + if application appName is running then + -e + log "Restarting " & appName + -e + ignoring application responses + -e + tell application appName to quit + -e + end ignoring + -e + repeat 60 times + -e + if application appName is not running then exit repeat + -e + delay 1 + -e + end repeat + -e + if application appName is running then + -e + log appName & " did not quit within 60 seconds; leaving it open." + -e + else + -e + do shell script "open -g -a " & quoted form of appName + -e + end if + -e + end if + -e + end repeat StartCalendarInterval Hour - 0 + 1 Minute 0 StandardErrorPath - /tmp/com.user.homebrew-update.err + /tmp/com.user.restart-browsers.err StandardOutPath - /tmp/com.user.homebrew-update.out + /tmp/com.user.restart-browsers.out -