I have a simple script:
caffeinate -di
that I saved as an app. When I click on the app it runs the process and stays in the dock. When I click on the Dock icon, it says "Application Not Responding" and the only way to terminate the process is to Force Quit.
Is there any way to write this script so that the normal "Quit" menu displays and I don't have to force quit it every time I want to stop it?
Best Answer
Any time an application does something like a execute a tight loop or perform a shell script that doesn't return, the user interface gets blocked because the app is not allowing the system time to process events. In this case an NSTask can be used, since it runs in the background, and the application is just used to start and stop it.
The following needs to be saved as a stay-open application - the shell script is launched and terminated with the app: