Login Script to check "prevent computer from sleeping"

Discussion in 'Mac Basics and Help' started by jagooch, Oct 25, 2018.

  1. jagooch macrumors 6502

    jagooch

    Joined:
    Jul 17, 2009
    Location:
    Denver, co
    #1
    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.
     
  2. hobowankenobi macrumors 6502a

    Joined:
    Aug 27, 2015
    Location:
    on the land line mr. smith.
    #2
    The preferred method of setting a preference like this would be with a profile.

    Would be global (for all users) and would supersede user set preferences.
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    Location:
    betwixt
    #3
    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.
     
  4. posguy99 macrumors 6502a

    Joined:
    Nov 3, 2004
    #4
    I would just use something like Amphetamine, to keep the machine awake.
     
  5. jagooch thread starter macrumors 6502

    jagooch

    Joined:
    Jul 17, 2009
    Location:
    Denver, co
    #5
    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 .
     
  6. hobowankenobi macrumors 6502a

    Joined:
    Aug 27, 2015
    Location:
    on the land line mr. smith.
    #6
    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!
     

Share This Page

5 October 25, 2018