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

Use location files to increase battery life System
OS X has the nice ability to define different "Locations" which can have different network settings (ie. Dial in numbers, DHCP settings, DNS settings, IP Addresses, etc) depending on where you are working. The desired location setting is easily selected from the Apple menu under "Locations"

The default Location as defined by Apple is called "Automatic" and includes settings for all the communication devices on my Powerbook (Modem, IR Port, Ethernet and Airport). However, I seldom need a connection to all 4 devices simultaneously (OS X can handle this and assign an IP address to each connection apparently) and really only use one connection at a time.

If you turn off unused devices, your laptop will power them down thus saving battery life. So creating separate Location profiles makes sense for the Laptop user trying to squeeze some more time out of the battery. To create additional Location Profiles:
  1. Open Network Preferences in System Preferences.
  2. Choose "New Location" under the Location dropdown menu selector.
  3. Give your new Location a name, ie. "Airport Only".
  4. A new Location will be created with all available devices present. Choose the "Network Ports Configuraion" under the Show drop down menu.
  5. Deselect all the other devices except the Airport.
That's it. I created one for "Ethernet Only", "Modem Only" and one called "No Network/Low Power" with no devices selected at all. I now find I can switch configurtions (OS X is nice enough to re-establish a connection on the fly when changing Locations without any hassle at all) instantly and save power for when I'm on the road. I've been able to increase my Laptop's battery life by 20 to 40 minutes when I'm in my "No Network/Low Power" mode which powers down the internal modem, IR Port, Ethernet, and Airport card. YMMV
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[8,554 views]  

Use location files to increase battery life | 8 comments | Create New Account
Click here to return to the 'Use location files to increase battery life' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
great hint but
Authored by: ateles on Dec 04, '02 01:09:57PM

This is a great hint! But you can edit the locations you already have to only detect the ports you need (not create new ones as implied by the original hint). So keeping it at automatic, you can go to a location (i.e. @ home where you only use Airport), in Sysem Prefs/Network, select Networks Port Configuration and deselect all other devices except Airport.

Great hint, DavidC

ateles



[ Reply to This | # ]
Need location-change triggered events
Authored by: silas on Dec 04, '02 01:12:00PM

I'm hoping that there will eventually be a way to trigger events based on location switches. I understand that such a thing was possible pre-OS X (I'm a recent convert), and it would be great to run scripts, change other system settings, etc. based on your location. As the hint author noted, OS X handles location changes really gracefully, so this would be more of an advanced feature, but one that folks who travel or have multiple "docks" would find useful. (e.g. start a system backup when I get to the office, shut down my database server when I join a public network, etc.)



[ Reply to This | # ]
Need location-change triggered events
Authored by: copelanduk on Dec 04, '02 02:17:13PM
I'm a big user of the network locations in Mac OS X, it's really a life saver. I also wanted to have events (not totally dissimilar to the examples you mentioned) triggered by changing locations. I remembered that I saw an article for a "dirty little script" that would change the smtp server for Mail.app when you changed locations. That stuff can be found here. The only problem is that I tried several times to edit my Kicker.xml file (see site linked above for full instructions) which is supposed to be able run a script based on the location changing, but I could never get it to work. I only tried for a little while and haven't gone back since. My suspicion was that it was a Jaguar related change (I was trying this stuff just after 10.2 was released). Anyway, I tunnel my mail traffic via ssh back to my home server and besides I have a .mac account so I can safely use their smtp server no matter what network I join, so I don't need everything from the site above. However, I could really use the capability to run certain scripts based on location. Basically | just ripped out the perl that queries the system for the current location: (note this is pretty much a copy from the site above, oh and I don't know perl yet, so it may be crappy code but it hasn't failed me so far.)
#!/usr/bin/perl -w # ------------------------------------------------------------------------------ # getLocation.pl written by Christopher Copeland 2002-09-02 # modified from script at http://interconnected.org/src/autosmtp/ # simple perl script that prints the current location # ------------------------------------------------------------------------------ use strict; my $location = &get_location_from_scutil() || ""; sub get_location_from_scutil { my @scutil = `scutil /dev/null open show Setup:/ close end_scutil`; my @matches = map { m/UserDefinedName : (.*)/ } @scutil; if(@matches == 1) { return $matches[0]; } else { return undef; } } print $location
So now I have getLocation.pl in my ~/bin/ and I use it all the time from other scripts. I've got a cron job that runs every 30 minutes and based on what location is returned by getLocation.pl, I can perform certain actions like rsync my files, starting apps or anything you might need doing. It would be cleaner if the scripts ran as a result of the Kicker noticing a location change, so I'll try to get that working over the holidays, but for now cron and the script above work well enough for my needs.

[ Reply to This | # ]
Need location-change triggered events
Authored by: cynikal on Dec 04, '02 05:35:10PM

or you could have done it in a one liner:

scselect 2>&1|awk '$1 ~ /^\*$/ {print $3}'|sed -e 's/[)(]//g'

If you want it to be called whenever the location changes, why not edit the script

/System/Library/SystemConfiguration/Kicker.bundle/Resources/set-hostname

so that it calls you're own script to perform whatever you need done when the location is changed.



[ Reply to This | # ]
Yes, but...
Authored by: chabig on Dec 04, '02 02:08:57PM

You are right. You can go to System Preferences, Network Pane, Show Network Port Configurations, and check/uncheck the ports you need/don't need. But the point of the hint (which I've been doing for a long time) is that it's much much simpler to go to the Apple menu, locations, and choose a new location. One menu choice, versus a series of preference windows.

Chris



[ Reply to This | # ]
The Hook Is There
Authored by: monickels on Dec 04, '02 02:24:43PM
I'm hoping that there will eventually be a way to trigger events based on location switches.

It does exist; at least, FireWalk does it: when you switch locations, Firewalk will switch its own settings to match those you used that last time you were connected to the particular location. So I believe all it would take is an awareness of how Firewalk is doing it, and applying that solution in other packages.

Also, don't overlook the shareware Location Manager. I am about to test it; it looks promising.

[ Reply to This | # ]
Multiple IP Addresses
Authored by: YuSung on Dec 05, '02 04:28:36PM

Just one comment. OS X not only allows you to have a separate IP address for each network connection (IR, ethernet, modem etc.), but also allows you to set up multiple IP addresses for the same network connection. While this may not seem all that useful, it can actually be quite useful when providing servers from behind a NAT server.



[ Reply to This | # ]
Apache Webserver / Internet Explorer conflict
Authored by: megasad on Dec 09, '02 10:10:28PM

Warning - If you switch off your Ethernet port, Internet Explorer will not be able to display locally served websites when you are not connected to the Internet via Modem. To fix; reactivate Ethernet port.



[ Reply to This | # ]