quit & quit_kill

Should be great for certain service apps, that we want to kill politely. Before use it should be checked it will not respawn automatically.
This commit is contained in:
Søren Theilgaard
2021-05-26 09:41:30 +02:00
parent 05635a76df
commit 31c18118ac

View File

@@ -34,6 +34,9 @@ NOTIFY=success
BLOCKING_PROCESS_ACTION=prompt_user
# options:
# - ignore continue even when blocking processes are found
# - quit app will be told to quit nicely, if running
# - quit_kill told to quit twice, then it will be killed
# Could be great for service apps, if they do not respawn
# - silent_fail exit script without prompt or installation
# - prompt_user show a user dialog for each blocking process found
# abort after three attempts to quit
@@ -379,6 +382,18 @@ checkRunningProcesses() {
appClosed=1
case $BLOCKING_PROCESS_ACTION in
quit|quit_kill)
printlog "telling app $x to quit"
runAsUser osascript -e "tell app \"$x\" to quit"
if [[ $i > 2 && $BLOCKING_PROCESS_ACTION = "quit_kill" ]]; then
printlog "Changing BLOCKING_PROCESS_ACTION to kill"
BLOCKING_PROCESS_ACTION=kill
else
# give the user a bit of time to quit apps
printlog "waiting 30 seconds for processes to quit"
sleep 30
fi
;;
kill)
printlog "killing process $x"
pkill $x