I want to change these behaviors from terminal:
- Auto-login
- Showing password after screensaver and sleep mode
- Go to sleep mode after x minutes
- Enable screensaver after x minutes
|
|
|
1) Auto-login That one is tricky. The default is saved in
But in order to turn it on or off, you need to do it as root. Set it:
Delete it (turn it off):
2) Showing password after screensaver and sleep mode I've been trying to get that one to work, and I can't You will see a lot of hints telling you that the answer is
or variations like
and that should work, because if you turn it off via System Preferences, you will see:
and then if you turn it back on via System Preferences, you will see
BUT if turn it OFF and the quit System Preferences and change the setting using 'defaults write', when I re-launch System Preferences, it does not reflect that change. I'd really like to know the answer to that one (preferably without osascript, but if there is no other way, I'll accept it). 3) Go to sleep mode after x minutes Assuming you mean "have the computer go to sleep after x minutes" you want:
You can also use different settings specifically for when you are on battery (for MacBooks):
If you want to specify never sleeping when plugged in, use
4) Enable screensaver after x minutes @Daniel's recommendation worked for me:
You can use 'sudo pmset displaysleep X' to have the display sleep instead of using the screensaver. |
|||||||||
|
|
The osascript command and the System Events application are your friends here. Basically, you will be calling AppleScripts from the command line. For instance,
The first sets the screensaver to 30 seconds after the last action; the second disables autologin. The third requires a password for exiting the screensaver or waking from sleep (the settings for the two are linked). Exploring the System Events dictionary will help you put together the specifics you are looking for. |
|||||
|
Screensaver Settings
To write to the system-wide file in
To write to the current user's file use
The value for a given setting in the user's file has priority over the value for the same setting in the system-wide file. |
|||||
|