Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Another script to set energy saver settings via pmset' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another script to set energy saver settings via pmset
Authored by: jeffulri on May 05, '04 01:49:33PM

Since this script sets iChat status to away in night time mode, you'll probably want it to also turn it to available in day time mode. So this will do that:

#!/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'
osascript -e 'tell application "iChat" to set status to available
tell application "iChat" to set status message to "Available"'
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

PS: I'm having what I'd like to call issues with the way this script is setting sound levels. It isn't actually muting the system volume in night time mode (I can still hear iTunes playing, but the system volume slider is at 0%), nor is it setting system sound volume to 100% (I'd prefer 75% actually) in day time mode. I'm not familiar enough with Applescript to KNOW how to address this issue, but fiddling with the number after "tell application "System Events" to set volume" doesn't yield results that I'd expect. Presumably, the variable range is 0 = no volume, 100 = full volume but 100 only sets my system volume to 50% -- as does 200 (I was just guessing here -- 75 too for that matter [Grin]). Any help on this issue would be greatly appreciated!



[ Reply to This | # ]