Viperfang Networks
Technical Insanity
RSS 2.0

Edit 20/05/2009: Realised I didnt attach a licence to this little project, so let it be the lastest version of the GPL, which at present is v3.  :-)

Before I start this, it should be known I am relatively new to shell scripts, and while this may not be the best method by any means, it does work.

Everything needed is available here as a tarball, it should be placed in /etc/apt/ and unpacked using ‘tar -xvf source-switcher.tar’, running source-swapper.sh will get you set up. You will have to configure your sources files though!

My problem was this. I have a local repo on a machine in my house, which makes updating and installing a lot quicker that it used to be, let alone being fun to set up. My laptop however, is not always in the house for obvious reasons, and even when it is,  it’s not always connected to the network.

For this, I wanted a way of switching between sources.list files with as little user intervention as possible.

I already have a folder called ’sources.safe’ which contains a different list for each location, and this is a listing so far:

root@ben-laptop:/etc/apt/sources.safe# ls -1
sources.CD-Rom
sources.Home
sources.Official

So I wrote this script which checks to see what repo is available, and copies the right sources.list and overwriting the one that is already there, and then notifies user 1000 (perfect for single user systems).

/etc/apt/source-swapper.sh
#!/bin/sh

apply()
{
export DISPLAY=:0.0
sudo -u \#1000 notify-send -u normal -t 10000 -i /etc/apt/apt.png “APT Source: $1″ ‘Your sources list has been updated for this network!’
cp “/etc/apt/sources.safe/sources.$1″ ‘/etc/apt/sources.list’
}

if wget -t 1 -T 1 –spider http://192.168.0.200/; then
apply ‘Home’
elif wget -t 1 -T 1 –spider http://archive.ubuntu.com/ubuntu/; then
apply ‘Official’
else
apply ‘CD-Rom’
fi

As you can see, the apply lines use the same extension as the sources files in the sources.safe folder. More scripts can be added by more else statements. This also allows prioritisation. Note that if all else fails it uses the CD-Rom sources list, this should allow me to have something to install from available at all times.

Also in my /etc/apt folder I created this script, which sets up the links in /etc/network/if-up.d and /etc/network/if-down.d so that the script runs when you ‘change location’.

/etc/apt/source-swapper-setup.sh
#!/bin/sh

echo ‘Setting up links…’

link /etc/apt/source-swapper.sh /etc/network/if-up.d/source-swapper
link /etc/apt/source-swapper.sh /etc/network/if-down.d/source-swapper

echo ‘making main script executable…’

chmod +x /etc/apt/source-swapper.sh

echo ‘Installing dependencies…’

apt-get -y install libnotify-bin

echo ’should be done :-)

A few things that should probably be noted. First is that the setup script will need to be set executable. If you decide not to use the setup script, make sure you manually apply its changes. The only other thing that have is the ‘package’ icon. That should be places in the apt folder as /etc/apt/apt.png, if you decide to place it elsewhere or which to use another image, you will need to adapt the script accordingly.

Here is the package icon. I got it from here: http://files.opensuse.org/opensuse/en/thumb/3/39/Icon-package.png/120px-Icon-package.png
apt

Here is an example notification from my laptop:
apt-source-home

There are more themes turning up that are officially from microsoft that are fully signed, meaning you don’t need to modify you windows XP install to use them, but were made instantly available to everybody for various reasons.

1) Royale Style (MCE Theme aka Energy Bliss)

This was provided with windows XP Media Centre Edition only, but has been extracted so it may be installed on any XP edition. This package also provides the Royale Noir style, thanks to http://samanathon.com/royale-noir-a-secret-xp-theme-uncovered-7/

Note: The download from here has been updated by comparison to that from samanathon.com

royale

royale-noir

2) Embedded Style

Provided as part of Windows XP Embedded, in the same way as MCE was.

embeded

3) Zune Style

The official microsoft Zune Style, but has been made into a zip instead of the msi that is provided directly from MS. This is a free download available to all.

zune

4) Luna Style

This is provided as part of any XP install, and has not been screenshot because of that. I have however provided it as a download, as I know how easily some of these files are lost.

5) Classic Theme

Provided for the same reason as the luna Style.

I hope these are useful, to install any of these these and styles, unzip into ‘<Windows Directory>\Resources\Themes’, for exampe, on my system it is C:\WINDOWS\Resources\Themes.