Actions
Actions can be taken given a particular location, the format is the same as all configuration files in laptop-location:
[Home] # Some actions to be performed [University] # Some actions to be performed
System actions are placed in /etc/laptop-location/actions and user actions are placed in ~/.laptop-location/actions
append
Append a line of text to a file, e.g.:
append /etc/apt/apt.conf.d/90proxy Acquire::http::Proxy "http://wwwproxy.cs.aau.dk:3128";
comment / #
Comments are ignored, but still read into the list of actions. This is done to be able to preserve them when saving the list of actions again using some graphical tool for manipulating laptop-location.
Comments can both be stated as comment and as the ubiquitous #-mark:
comment This is a comment # This is also a comment
When saving a list of actions, the #-mark version is used.
copy
Copy a file from one location to another, e.g.:
copy file_from file_to
proxy
Creates an automatic proxy configuration file, for use in browsers. This means that browsers that doesn't support the HTTP_PROXY variable or doesn't support other means of setting the proxy configuration automatically can just point to a laptop-location generated proxy.pac script.
The configuration script is called ~/.laptop-location/proxy.pac if run by the user - so to make your browser use that. Just point it to file:///home//.laptop-location/proxy.pac
If run in the global actions file, it writes to /etc/laptop-location/proxy.pac
To use the proxy action, use something like the following:
proxy wwwproxy.cs.aau.dk:3128
To allow for locations without a proxy server, the action can also be called without parameters:
proxy
remove
Removes the file given as the only parameter:
remove ~/stupid_useless_file
Can only remove files at the moment, no directories.
symlink
Creates/updates a symbolic link to point to a given file.
I use it to change the X11 configuration of my laptop, at home i have an secondary LCD display for my laptop that i would like to use with xinerama:
# Create a symlink for the correct X11 configuration, at home i have a # secondary LCD screen, and i would like to use that with Xinerama when home. [Home] symlink /etc/X11/xorg.conf.xinerama /etc/X11/xorg.conf [University] symlink /etc/X11/xorg.conf.standard /etc/X11/xorg.conf
system
Run any system command, run in another shell, or more specifically using the system call system:
system echo "The current location is here!" > ~/.why_not_use_etc_laptop_locations
touch
"Touch" a file, that is, update it's access time and modification time:
touch ~/some_file
User-only Actions
env
Sets an environment variable to a given value.
The environment values are set in a script called ~/.laptop-location/${HOSTNAME}-sh so to get the environment variables set in your shell you could add something like the following to your, e.g. ~/.bashrc:
source ~/.laptop-location/${HOSTNAME}-sh
The env construct looks like this:
env HTTP_PROXY http://wwwproxy.cs.aau.dk:3128/
gconf
Sets a given gconf key to a given value, if the value is already set in gconf the value given will be converted to the same gconf value as the old gconf value.
# At home i have direct connection to the internet [Home] gconf /system/http_proxy/use_http_proxy 0 # At the university i have to use a proxy [University] gconf /system/http_proxy/use_http_proxy 1 gconf /system/http_proxy/host wwwproxy.cs.aau.dk gconf /system/http_proxy/port 3128