home > linux > scripts > firefox-auto-profile-switcher

Firefox Auto Profile Switcher

| 14 Oct 2011

It's easy enough to add firefox profiles, but switching between them can be tedious, using a wrapped script, you can automate this task.

First you want to create a wrapper for firefox, this can be done easily two ways, either with update-alternatives or using a bash alias. To add a bash alias;

echo "alias firefox="/home/mike/bin/firefox-profiler.sh"" > ~/.bashrc

This will call our script instead of the path instance of firefox (alaiases take presidence)...

in our script now all we need to do is defrenciate a difference between the networks at home / work, this can be done on netmask or in my case if i'm using wireless or ethernet cable to connect.

Scirpt:
#!/bin/bash
# mike.j - 10/10/2011 - firefox profiler

checkEth0=$(/sbin/ifconfig eth0 | /bin/grep inet)
if [ -n "$checkEth0" ]; then
    /usr/bin/firefox -P "work"
else
    /usr/bin/firefox -P "home"
fi

If you are linking this script from the main menu or panels, you will need to either export the environment variable path or just use fully qualified paths inside the script.

Post a Comment