Thanks a lot for the tip, I made a script called by udev when my QuickCam get plugged to switch the input-source in pulse-audio. It is ugly, but works for now.
So I created /etc/udev/rules.d/97-QuickCam_E2500.rules
Code:
SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="046d", ATTR{idProduct}=="089d", RUN+="/usr/local/bin/QuickCam_E2500_hotplug.sh"
Then /usr/local/bin/QuickCam_E2500_hotplug.sh
Code:
#!/bin/bash
delegate=`dirname $0`/QuickCam_E2500_hotplug_delegate.sh
$delegate &
Since I could'nt find how to get called after pulseaudio was updated, I had to create the following delegate that tries every second for 5 seconds. So the file /usr/local/bin/QuickCam_E2500_hotplug_delegate.sh contains:
Code:
#!/bin/bash
#Configure this as your home directory
export HOME=/home/#Your username
#Configure this as your username. If you have multiple user on your computer, you'll have to adapt this script.
pulseaudio_user=#Your username
#Those are the vendor and product id of your usb device, as found in:
# udevadm info --attribute-walk --path=/sys/devices/pci0000\:00/0000\:00\:1d.1/usb3/3-1/input/input12/
# look at the output of dmesg to find the right path. Those numbers are also found directly in dmesg:
# ...
# gspca: probing 046d:089d
# ...
# and in the pulse audio card name eg: usb-046d_089d-01-U0x46d0x89d. In fact we only match the pulseaudio
# card name.
idvendor="046d"
idproduct="089d"
# poll pulseaudio for the newly plugged card.
counter=0
while [ $counter -lt 5 ] ; do
srcname=`sudo -u $pulseaudio_user pacmd dump | grep "set-card-profile.*$idvendor.*$idproduct.*input" | sed -ne 's/.*\.\([^ ]*\) input:\(.*\)/alsa_input.\1.\2/p'`
if [ ! -e $srcname ] ; then
break
fi
sleep 1
let counter=counter+1
done
# Set it as the default source.
if [ ! -e $srcname ] ; then
sudo -u $pulseaudio_user pacmd set-default-source $srcname
fi