Ubuntu – How to force Empathy Internet Messaging to change default webcam

11.10defaultempathyusbwebcam

I just recently bought a new webcam. It is USB powered. For personal reasons, I wish to not use the built in webcam that came with my netbook.

I want to use this new one. I love empathy, it is a great chat client. But, I can't seem to switch my default webcam in empathy from the built in webcam, to the one I just bought.

So, is there a way to force empathy to use the USB powered webcam, rather than the built in webcam?

Let's eliminate some options.

  1. I tried the gstreamer-properties method, root and normal user. No use.

  2. I tried the configuration editor method as-well, trying to manually change web-cam defaults.

  3. I also tried blacklisting the built in web-cams driver, but my second web-cam also
    runs off that same driver so that option was pointless because it disabled both web-cams, instead of the one I needed to use.

Best Answer

  • What you want I think is udev rules.

    I'm on 12.04 so your mileage may vary, but here's an example:
    You want to change switch /dev/video1 and /dev/video0. First get the info you need:
    udevadm info -a -p $(udevadm info -q path -n /dev/video0)
    udevadm info -a -p $(udevadm info -q path -n /dev/video1)
    Copy both of those huge blocks of text into gedit
    Mine looked like this:

      looking at device '/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1:1.0/video4linux/video0':
        KERNEL=="video0"
        SUBSYSTEM=="video4linux"
        DRIVER==""
        ATTR{name}=="USB2.0 PC CAMERA"
        ATTR{index}=="0"
    
      looking at parent device '/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1:1.0':
        KERNELS=="1-1:1.0"
        SUBSYSTEMS=="usb"
        DRIVERS=="uvcvideo"
        ATTRS{bInterfaceNumber}=="00"
        ATTRS{bAlternateSetting}==" 0"
        ATTRS{bNumEndpoints}=="01"
        ATTRS{bInterfaceClass}=="0e"
        ATTRS{bInterfaceSubClass}=="01"
        ATTRS{bInterfaceProtocol}=="00"
        ATTRS{supports_autosuspend}=="1"
        ATTRS{iad_bFirstInterface}=="00"
        ATTRS{iad_bInterfaceCount}=="02"
        ATTRS{iad_bFunctionClass}=="0e"
        ATTRS{iad_bFunctionSubClass}=="03"
        ATTRS{iad_bFunctionProtocol}=="00"
    
      looking at parent device '/devices/pci0000:00/0000:00:12.2/usb1/1-1':
        KERNELS=="1-1"
        SUBSYSTEMS=="usb"
        DRIVERS=="usb"
        ATTRS{configuration}==""
        ATTRS{bNumInterfaces}==" 4"
        ATTRS{bConfigurationValue}=="1"
        ATTRS{bmAttributes}=="80"
        ATTRS{bMaxPower}=="320mA"
        ATTRS{urbnum}=="5064"
        ATTRS{idVendor}=="18ec"
        ATTRS{idProduct}=="3299"
        ATTRS{bcdDevice}=="0100"
        ATTRS{bDeviceClass}=="ef"
        ATTRS{bDeviceSubClass}=="02"
        ATTRS{bDeviceProtocol}=="01"
        ATTRS{bNumConfigurations}=="1"
        ATTRS{bMaxPacketSize0}=="64"
        ATTRS{speed}=="480"
        ATTRS{busnum}=="1"
        ATTRS{devnum}=="14"
        ATTRS{devpath}=="1"
        ATTRS{version}==" 2.00"
        ATTRS{maxchild}=="0"
        ATTRS{quirks}=="0x0"
        ATTRS{avoid_reset_quirk}=="0"
        ATTRS{authorized}=="1"
        ATTRS{manufacturer}=="ARKMICRO"
        ATTRS{product}=="USB2.0 PC CAMERA"
    
      looking at parent device '/devices/pci0000:00/0000:00:12.2/usb1':
        KERNELS=="usb1"
        SUBSYSTEMS=="usb"
        DRIVERS=="usb"
        ATTRS{configuration}==""
        ATTRS{bNumInterfaces}==" 1"
        ATTRS{bConfigurationValue}=="1"
        ATTRS{bmAttributes}=="e0"
        ATTRS{bMaxPower}=="  0mA"
        ATTRS{urbnum}=="324"
        ATTRS{idVendor}=="1d6b"
        ATTRS{idProduct}=="0002"
        ATTRS{bcdDevice}=="0302"
        ATTRS{bDeviceClass}=="09"
        ATTRS{bDeviceSubClass}=="00"
        ATTRS{bDeviceProtocol}=="00"
        ATTRS{bNumConfigurations}=="1"
        ATTRS{bMaxPacketSize0}=="64"
        ATTRS{speed}=="480"
        ATTRS{busnum}=="1"
        ATTRS{devnum}=="1"
        ATTRS{devpath}=="0"
        ATTRS{version}==" 2.00"
        ATTRS{maxchild}=="6"
        ATTRS{quirks}=="0x0"
        ATTRS{avoid_reset_quirk}=="0"
        ATTRS{authorized}=="1"
        ATTRS{manufacturer}=="Linux 3.2.0-22-generic ehci_hcd"
        ATTRS{product}=="EHCI Host Controller"
        ATTRS{serial}=="0000:00:12.2"
        ATTRS{authorized_default}=="1"
    
      looking at parent device '/devices/pci0000:00/0000:00:12.2':
        KERNELS=="0000:00:12.2"
        SUBSYSTEMS=="pci"
        DRIVERS=="ehci_hcd"
        ATTRS{vendor}=="0x1002"
        ATTRS{device}=="0x4396"
        ATTRS{subsystem_vendor}=="0x1043"
        ATTRS{subsystem_device}=="0x8389"
        ATTRS{class}=="0x0c0320"
        ATTRS{irq}=="17"
        ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f"
        ATTRS{local_cpulist}=="0-3"
        ATTRS{numa_node}=="0"
        ATTRS{dma_mask_bits}=="32"
        ATTRS{consistent_dma_mask_bits}=="32"
        ATTRS{broken_parity_status}=="0"
        ATTRS{msi_bus}==""
        ATTRS{companion}==""
        ATTRS{uframe_periodic_max}=="100"
    
      looking at parent device '/devices/pci0000:00':
        KERNELS=="pci0000:00"
        SUBSYSTEMS==""
        DRIVERS==""
    

    You're looking for the attributes from lsusb that match your camera:

    SUBSYSTEMS=="usb"
    ATTRS{idVendor}=="firsthalf"
    ATTRS{idProduct}=="secondhalf"
    

    Then as root you edit your /etc/udev/rules.d/25-video-device.rules
    That name is relatively arbitrary. The number has to do with what sets get parsed first, but it pops up in a lot of udev google searches. Let's just use it.

    Mine looks like:

    SUBSYSTEMS=="usb", ATTRS{idVendor}=="18ec", ATTRS{idProduct}=="3298", NAME:="video0", OPTIONS:="link_priority=100"
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="090c", ATTRS{idProduct}=="c371", NAME:="video2"
    

    Save the file

    Some sources indicate as root service udev restart, but I got a hard lock. So just reboot with it plugged in.
    Now fire up anything that doesn't let you choose a video device. Since they're probably hard-wired to use /dev/video0, this should "just work".

    For whatever reason, at least for me, it won't over-ride and displace the existing video0, it just creates two files(maybe by design). You could ln -sf /dev/video1 /dev/video0. For me devices I specified this way seem to work. I tested with guvcview.

    Congratulations, you just wrote a udev rule to overcome a hard-coded url.

    You can specify to run commands at the ends of those udev rules too.

    SUBSYSTEMS=="usb", ATTRS{idVendor}=="18ec", ATTRS{idProduct}=="3298", NAME:="video0", OPTIONS:="link_priority=100", RUN+="ln -sf /dev/video1 /dev/video0"
    
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="090c", ATTRS{idProduct}=="c371", NAME:="video2"
    

    Now your USB video occupies /dev/video0 and /dev/video1. You don't lose your built-in either since now it's located at /dev/video2.