Last active
December 24, 2021 16:33
-
-
Save theoknock/1a4d5334489b905b57834d9589b021b6 to your computer and use it in GitHub Desktop.
A keepalive script for Mac OS X apps, which takes the process name of the app as its only argument; recursively executes every one second to ensure the target app is still running (it also sets the input volume of the device to maximum)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Continuously monitor the run state of an app | |
# identified by the specified name and | |
# launches the app if not running | |
while (true); do | |
ps_out=`ps -ef | grep $1 | grep -v 'grep' | grep -v $0` | |
result=$(echo $ps_out | grep "$1") | |
if [[ "$result" == "" ]]; then | |
open -a /Applications/AVS\ Server.app/ | |
osascript -e "set volume input volume 100" | |
osascript <<END | |
tell application "Finder" | |
if exists application process "$1" then | |
set visible of application process "$1" to false | |
end if | |
end tell | |
END | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To execute:
./keepalive_process [process name]