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.
66 lines
2.5 KiB
Plaintext
66 lines
2.5 KiB
Plaintext
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>Label</key>
|
|
<string>com.user.restart-browsers</string>
|
|
<!--
|
|
Quits each running browser 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. The first run asks for permission to control
|
|
each browser (System Settings > Privacy & Security > Automation).
|
|
-->
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>/usr/bin/osascript</string>
|
|
<string>-e</string>
|
|
<string>repeat with appName in {"Google Chrome", "Vivaldi", "Floorp"}</string>
|
|
<string>-e</string>
|
|
<string>set appName to contents of appName</string>
|
|
<string>-e</string>
|
|
<string>if application appName is running then</string>
|
|
<string>-e</string>
|
|
<string>log "Restarting " & appName</string>
|
|
<string>-e</string>
|
|
<string>ignoring application responses</string>
|
|
<string>-e</string>
|
|
<string>tell application appName to quit</string>
|
|
<string>-e</string>
|
|
<string>end ignoring</string>
|
|
<string>-e</string>
|
|
<string>repeat 60 times</string>
|
|
<string>-e</string>
|
|
<string>if application appName is not running then exit repeat</string>
|
|
<string>-e</string>
|
|
<string>delay 1</string>
|
|
<string>-e</string>
|
|
<string>end repeat</string>
|
|
<string>-e</string>
|
|
<string>if application appName is running then</string>
|
|
<string>-e</string>
|
|
<string>log appName & " did not quit within 60 seconds; leaving it open."</string>
|
|
<string>-e</string>
|
|
<string>else</string>
|
|
<string>-e</string>
|
|
<string>do shell script "open -g -a " & quoted form of appName</string>
|
|
<string>-e</string>
|
|
<string>end if</string>
|
|
<string>-e</string>
|
|
<string>end if</string>
|
|
<string>-e</string>
|
|
<string>end repeat</string>
|
|
</array>
|
|
<key>StartCalendarInterval</key>
|
|
<dict>
|
|
<key>Hour</key>
|
|
<integer>1</integer>
|
|
<key>Minute</key>
|
|
<integer>0</integer>
|
|
</dict>
|
|
<key>StandardErrorPath</key>
|
|
<string>/tmp/com.user.restart-browsers.err</string>
|
|
<key>StandardOutPath</key>
|
|
<string>/tmp/com.user.restart-browsers.out</string>
|
|
</dict>
|
|
</plist>
|