Well, these commands edit .plist files in your /Users/xyz/Library/Preferences folder. So, if you look at these files, you can look at these files and base your Terminal commands after these.
These are XML-based files, so you can view them in a more readable format if you open them in Xcode, which is available in the Mac App Store.
In the Terminal, the format for these is "defaults write PLIST_FILE KEY -TYPE VALUE"
where the PLIST_FILE is the name of the file in the Preferences folder without the .plist, KEY is the key that you can see in Xcode, -TYPE is the type of key that you can find Xcode (and you can find if there is an abbreviation for that type by typing "defaults" into the terminal), and value is the value you wish to set the key at.
Here are some of the string types from the Terminal:
-string <string_value>
-data <hex_digits>
-int[eger] <integer_value>
-float <floating-point_value>
-bool[ean] (true | false | yes | no)
-date <date_rep>
-array <value1> <value2> ...
-array-add <value1> <value2> ...
-dict <key1> <value1> <key2> <value2> ...
-dict-add <key1> <value1> ...
AppleScript is a nice way to go !
tell application "System Preferences"
reveal pane "com.apple.preference.mouse"
end tell
tell application "System Events" to tell process "System Preferences"
tell checkbox 1 of window 1
click
end tell
end tell
It works on Mavericks. It might need some modifications on older OS X because the UI of the mouse preferences changed.
Best Answer
1) Auto-login
That one is tricky. The default is saved in
defaults read /Library/Preferences/com.apple.loginwindow autoLoginUser
But in order to turn it on or off, you need to do it as root.
Set it:
sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser ShortName
Delete it (turn it off):
sudo defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser
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.