Combining UNIX commands into one task
Here's the series of commands I have ended up with:
defaults -currentHost write com.apple.screensaver idleTime 1
defaults write ~/Library/Preferences/ByHost/com.apple.screensaver.$(ifconfig en0 | awk '/ether/{gsub(/:/,"");print $2}') askForPassword -int 1
defaults -currentHost write com.apple.screensaver idleTime 0
# Set amount of idle time in minutes until a computer sleeps. Specify "Never" or "Off" for computers that should never sleep.
systemsetup -setsleep 45
# Set the amount of idle time in minutes until the hard disk sleeps.
systemsetup -setharddisksleep 90
# Set the amount of idle time in minutes until the display sleeps.
systemsetup -setdisplaysleep 15
Thanks