May 05, '04 09:17:00AM • Contributed by: Anonymous
Daytime sets the monitor to dim at 20 minutes, the hard drive to spin down in 10 minutes, the volume to 4, and processor speed to automatic. Nighttime sets the monitor to dim at 1 minute, the hard drive to spin down in 1 min, the volume to mute, and the processor speed to reduced. Sleep sets the computer to sleep in 1 min, and only wakes on a magic packet.
Read the rest of the hint for the script...
[robg adds: This script seems to work as described ... and there are a few more pmset hints here; it's a very handy command...]
The script:
#!/bin/bash
# pmset script
function usage
{
echo "Usage: [-h | --help] | [ [-n --night] [-d --day] [-s --sleep] ]"
}
if [ $(id -u) = "0" ]; then
echo
else
usage
echo "Must be run as root..."
exit 1
fi
mode=
case $1 in
-n | --night ) mode=1
;;
-d | --day ) mode=2
;;
-s | --sleep ) mode=3
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
if [ "$mode" = "1" ]; then
pmset womp 1 dps 0 dim 1 reduce 1 autorestart 1 spindown 1 sleep 0 acwake 0 ring 0;
osascript -e 'tell application "System Events" to set volume 0'
osascript -e 'tell application "iChat" to set status to away
tell application "iChat" to set status message to "Away"'
echo "$HOSTNAME set to nighttime mode";
fi
if [ "$mode" = "2" ]; then
pmset womp 1 dps 1 dim 20 reduce 0 autorestart 1 spindown 10 sleep 0 acwake 0 ring 1
osascript -e 'tell application "System Events" to set volume 4'
echo "$HOSTNAME set to daytime mode"
fi
if [ "$mode" = "3" ]; then
pmset womp 0 dps 0 dim 1 reduce 1 autorestart 1 spindown 1 sleep 1 acwake 0 ring 0
echo "$HOSTNAME set to sleep/dormant mode"
fi
exit
