KDEprofile switcher

Problem I use a laptop with 21" monitor at home but no monitor on the road. The amount of screen real estate changes drastically from 1792x1344 plus resolution down to 1280x800. The fonts and other items on the screen take up too much room in the smaller resolution and are too small in the larger resolution.

Solution To solve this problem (for KDE anyway) I created this script which will change a symlink based on the current resolution. It will start with the smallest profile it finds and try to match that resolution. If the current resolution is less than or equal to the profile it will create the link to it. Otherwise it will try the next profile. If it gets to the end without a match it simply uses the largest profile found.

Setup To use it you need to run it while logging in. I placed it in ~/bin and created a file in my home directory called .xsession which looks like this:

#!/bin/sh
$HOME/bin/kdeprofile
exec startkde

At the kdm screen I choose Default as the session type. The script will look for kde directories with resolutions tacked onto them in your home directory. For example, I booted into the 1280x800 setup and sized everything like I wanted it. Then I exited my session and renamed the .kde directory to .kde-1280 with this command:
mv $HOME/.kde $HOME/.kde-1280

Then I repeated the process with the monitor plugged in:
mv $HOME/.kde $HOME/.kde-1792

Only if $HOME/.kde is a symlink will the script continue. If a directory already exists the program will not touch it. If the directory does not exist the program will not create it or the symlink. So after renaming your directories manually link one of them
cd $HOME && ln -s .kde-1280 .kde