Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jagooch

macrumors 6502a
Original poster
Jul 17, 2009
823
257
Denver, co
I'm looking for the terminal / shell commands to turn on "prevent computer from sleeping" in power settings. I can check it manually in System Preferenes->Power..->"prevent computer from sleeping" , but it unchecks itself when I reboot. Since I'm using a corporate Macbook, there may be a company policy/login script that unchecks the setting.

It wouldn't be a problem if I didn't use ssh a lot to do my work. If I lock my computer to go to lunch or other reason, when I come back all of my ssh sessions are disconnected.

Google hasn't been my friend on this as it returns apps like Caffeine ( which I have ) or tells me to check the feature that I already know how to check.

I messed around with
defaults domains
and
defaults read com.apple.systempreferences

but didn't find anything to do with sleep.

Ideas and recommendations would be appreciated.
 
The Terminal command you should look at is called 'pmset'.

It will let read the current settings, as well as change them, if they're actually changeable. You'll be able to check the results of any cmd-line invocations, by reading back the setting you just changed and seeing if it "took". You should also be able to see changes in the Power prefs pane reflected in pmset's output.
 
I would just use something like Amphetamine, to keep the machine awake.
But for security reasons ( shared workspace) I have to lock it when I leave the area . When I return and unlock it , my VPN and ssh sessions are all disconnected .
 
Are you on Wifi?

Default as far as I know, is that wifi gets disconnected at lock or log out. Obviously that would kill all network related services.

If yes....I found this (untested, so don't blame or credit me):



If you now complain that the Wifi is disconnected when you do lock your Mac:
  1. Find your Wifi network card name, it should be en0 or en1 ( try in Terminal: ifconfig|grep ^en )
  2. In a Terminal: sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport en0 prefs DisconnectOnLogout=NO
  3. Type your password when requested
This change is one shot and persistent! You only need to run it once and you’re done!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.