Trying to Disable App Nap System Wide in El Capitan

msnowdon
Contributor

I found this command to disable app nap through terminal:
defaults write NSGlobalDomain NSAppSleepDisabled -bool YES

It seems to work if I manually type it into terminal but not if I put it in a policy to execute the command. Is it because Casper runs it as root?

How can I push it out and be effective for all users?

Thanks

9 REPLIES 9

mm2270
Legendary Contributor II

NSGlobalDomain is affecting the ~/Library/Preferences/.GlobalPreferences.plist file in this case. (Note the period in its name, meaning its hidden) So yes, you're assumption is correct. This is applying a setting to a local user level hidden plist. Running it from Casper will be running it as root so its not going to make the change to that plist.

BTW, I'm not so certain that command is disabling App Nap 'System-wide', since, again, its writing to a user level plist. Have you verified that it remains off for any account that logs in? I assume you're relaunching apps and checking in Activity Monitor for them in the Energy tab to check their state?

I haven't tried this, but its possible writing that same value into the actual top level .GlobalPreferences.plist may work. As in:

defaults write /Library/Preferences/.GlobalPreferences.plist NSAppSleepDisabled -bool YES

msnowdon
Contributor

@mm2270 , By system wide, I meant all apps as opposed to singling out individual apps. When I type it in manually it seems to work but as you mentioned, it only works for that particular user and not everyone. I'll test out your command and let you know if it works and affects all users.

Thanks

mm2270
Legendary Contributor II

OK, gotcha on what you meant. If you only care about affecting the main user, or if there is only ever one person per Mac, then as long as you can target the correct plist, it should work.
However, taking a step back, you may want to see if you can do this with a Configuration Profile. For example, write the value into a new plist on the Desktop and then use mcxToProfile to convert it into a .mobileconfig profile. Upload to Casper and apply at the user level. That may get you what you're after but with the advantage of it being in a profile that can apply to any user on the box.

msnowdon
Contributor

@mm2270 I ended up trying your first suggestion and so far it has been working fine.

Thanks

Mark

djdavetrouble
Contributor III

What advantages does this offer? Just curious!

msnowdon
Contributor

Many of my users are having that common problem of going to use their MacBook and it's suddenly non-responsive. Cant click on the Apple, can't type, can't use the track pad. They can launch apps but cant do anything with them. I been searching everywhere for a cause and everyone seems to have their own ideas of what is happening. I thought by turning off App Nap, it might help the issue. I thought it helped at first but the problem seemed to have come back. I find that forcing it to sleep using Option Command Eject, waiting a minute and waking it back up seems to get it to respond again.

This issue has been frustrating my users since Mavericks and hasn't seemed to get any better. I also tried disabling hibernation but I don't think that did anything but wear down the battery a lot quicker.

bentoms
Honored Contributor III
Honored Contributor III

@msnowdon Maybe it's caused by a login window profile? As mentioned here

msnowdon
Contributor

@bentoms Thanks, I will have a look at that. I'll be so happy if that helps me resolve my issue.

@mm2270 Like the original post, I'm trying to use the same method to shut off the system's auto correct for all users.

I tried applying this command but didn't seem to work:

defaults write /Library/Preferences/.GlobalPreferences.plist NSAutomaticSpellingCorrectionEnabled -bool NO

Any ideas?

msnowdon
Contributor

@bentoms I finally got to go through your findings. Incredible detective work, I must say. I removed a Security & Privacy profile and a Login Window profile I have going to all my clients from a test machine. I created the combo profile as you suggested in your documentation and applied that profile to my test machine. I also unchecked the "Combine available workgroup settings" option from the Access tab of the Login Window payload. My machines are bound to AD but not Open Directory and I'm not quite sure what that setting does.

After applying the new combo profile to my test machine, I checked for the presence of the com.apple.Spotlight.plist. It was no longer there but was there before the change. Also I see the drop in CPU usage from Spotlight compared to a machine that still has the old profiles.

Now the real test will be to see if the "non-response after waking from sleep" issue goes away. It was intermittent and seemed to affect some users more than others.

I also printed out the Managed Client portion of System Information before and after the change and going to compare the two. I also want to read the Payload Best Practices documentation from Apple so I can get a better handle on managing profiles.

Thank you very much for 1, doing the research and 2 sharing it with me. All clients of JAMF should be made aware of these issues if they are not already.

Thanks again,

Mark Snowdon