Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable app nap for Ruby on Mavericks

Is there a way to globally disable App Nap when running Ruby. I have a custom version installed via RVM which I can Get Info on in the Finder but the "Disable App Nap" option is not there. I don't know the domain name of Ruby to try the command line option: "defaults write ruby NSAppSleepDisabled -bool YES". I tried ruby, org.ruby, org.ruby.ruby, and org.ruby-lang.ruby before giving up.

like image 378
Jason Avatar asked Mar 31 '14 22:03

Jason


2 Answers

There's nothing to disable; the Ruby interpreter (among most other command-line applications) is not subject to App Nap.

You may verify this from the "Energy" tab of Activity Monitor. You might need to make the "App Nap" column visible if it isn't already.

like image 147
colinm Avatar answered Sep 23 '22 15:09

colinm


App Nap is per app basis. You don't want to disable it for anything that uses Ruby.

An app is supposed to tell the system when the app is not allowed to nap (e.g, when you start a task), and when it is allowed back to nap (e.g, when the task ends). This would be done using NSProcessInfo class in Obj-C. Unfortunately that might mean finding a way to talk to Obj-C via a route such as Ruby -> C/C++ -> Obj-C, but such is the consequence of straying away from native libraries.

App Nap can be disabled entirely per app by setting the boolean user default key NSAppSleepDisabled to YES like you discovered. Via terminal, this could be done:

defaults write appbundleidentifier NSAppSleepDisabled -bool YES

This requires having set up an Info.plist in your app with your own bundle identifier.

Also, I believe if you link with the 10.8 SDK as opposed to the 10.9 SDK, you might get a "Prevent App Nap" checkbox when you Get Info on an application. The reasoning behind this is that if you link to 10.9 SDK, you are expected to implement App Nap for 10.9.

like image 42
Zorg Avatar answered Sep 22 '22 15:09

Zorg