Linux Skype Webcam Fix

I have always had bad luck with webcams under Linux, but it is usually application specific. With some apps the device works, with some it doesn't. The most notoriously troublesome app for webcam use in Linux is Skype. Luckily, I have found a fix, and one that works with other apps you may be having problems with as well. This fix is really for Ubuntu Hardy, Intrepid and Jaunty, which by default load the wrong v4l driver for my Logitech webcam. Gutsy, for whatever reason, does not need this fix. This fix may or may not work on other distros as well, depending on what problem you are having with your webcam.

First off, make sure you have a bin directory in your home directory. If not, open a console and type:

$ mkdir ~/bin

Next, make sure that your ~/bin directory is in your program path, and make sure it comes before /usr/bin.

$ env | grep PATH

If you do not see '/home/your_user_name/bin in the list, you need to add it. If you do see it, make sure it comes before /usr/bin. To add ~/bin to the list, edit the ~/.bashrc file with your favorite text editor, and add the following line to the end of the file:

export PATH=/home/your_user_name/bin:$PATH

This will set the PATH environment variable correctly every time you log in. You will have to log out and log back in for the changes to take effect in your current X session.

Now we need to apply our fix. Go to the ~/bin directory and create a file called 'skype'. Edit this file to contain the following:

#!/bin/bash
export LD_PRELOAD=/usr/local/lib/libv4l/v4l1compat.so
/usr/bin/skype

Save the file. This is a wrapper script that will force your webcam to load the correct v4l driver. It is important to note that we specify the full path to skype, because calling 'skype' without it will execute this script again, and you will forkbomb your system. Next, we must make the script executable with the chmod command:

$ cd ~/bin
$ chmod a+x skype

Now, whenever a launcher calls 'skype' without specifying a path, it will default to calling your wrapper script, and the correct driver will be loaded. I hope someone finds this as useful as I did!