I often (for example on the train) want to put my macbook into a state that will maximise the amount of time I have before the battery runs out - so far example I'll switch off the bluetooth, then switch off the wifi, then alter the brightness - my question is, can I do all of this from the command line? Then I run some nice little script...
You can, but you will need some extra utilities:
brightness - you can download the program at http://dev.sabi.net/svn/dev/trunk/LocationDo/brightness.c and compile it using the command:
Or you can just download it from my server at http://attic.luo.ma/brightness.bz2
Once you have it,
Bluetooth - The command you want is
Whichever program you use, the
Wi-Fi - You can turn AirPort power on or off using:
You can find out which it is using
For my MacBook Air (which uses en0), the command to turn it off is:
Be sure that you have changed the Energy Settings in System Preferences too, but you can also set them using:
to tell the computer to sleep after 10 minutes when on battery, and/or:
to tell the computer display to sleep after 5 minutes, when on battery (the -b flag indicates battery).
will show you your current settings.