hi !
im currently working for an art exhibition for the museum of film in frankfurt. the people there ask for an easy way to switch on/off the installation. For off-switching they have to press ESC, point on the apple icon in the left upper corner, select “ausschalten…” and so on. is there a way to shutdown inside openframeworks app ?
i usually do it like that:
most exhibitions have fixed closing times so you just have to program your mac to switch off automatically after the closing hour. you can do that in the system settings -> energy saver -> schedule or systemeinstellungen -> energie sparen -> zeitplan… on a german system.
but sometimes applications can veto the shutdown then you’ll have to quit the program before or have it quit by itself at a certain time. for my last installations i wrote a shell script to kill my program or restart it in case of premature crash.
I am using the following code-snippet. Essentially you are sending an apple-event to the system process, this is the same, as choosing “shutdown” from the apple-menu.
Hey !
Thank you all a lot ! The code from " sth " works quite well. When you put " OSErr error = SendAppleEventToSystemProcess(kAEShutDown); " in testApp::keyPressed it even goes down when you hit ESC. another thing: my application is not focused when i start it as a startup item, so you first have to click on it then you can do keypressing-events. how can i focuse it ?
Seems like you have solved most of the problems, but one tip is to use launchd to assure that if your app crashes, it auto restarts. You can use the oensource program Lingo to easy set it up.
We also use mac’s for exhibitions with limited access to the mac computers.
I made this small app that runs and listens to the Notification = com.apple.logoutInitiated
Basically when you pressed the mac power button once it shuts down. you don’t have to choose and click any button in the “are you sure you want to shut down your computer now” window.
i often just run a shell script to shut down a machine (in case there are problems).
sudo -S shutdown now
since shutdown is a protected command, i have to load in the admin password, which isn’t the safest thing but fun for an exhibition computer that nobody has access to.
sudo -S shutdown now < $HOME/linktpasswordinatextfile
i could never figure out how to keep that as a single command.