禁用Ruby on Mavericks上的app nap

Jas*_*son 5 ruby osx-mavericks

有没有办法在运行Ruby时全局禁用App Nap.我有一个通过RVM安装的自定义版本,我可以在Finder中获取信息但是"禁用App Nap"选项不存在.我不知道Ruby的域名来尝试命令行选项:"defaults write ruby​​ NSAppSleepDisabled -bool YES".我放弃之前尝试过ruby,org.ruby,org.ruby.ruby和org.ruby-lang.ruby.

Zor*_*org 2

App Nap 以每个应用程序为基础。您不想为任何使用 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
Run Code Online (Sandbox Code Playgroud)

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.