udev rule + script for setting webcam's mic as audio input


 
Thread Tools Search this Thread
Operating Systems Linux udev rule + script for setting webcam's mic as audio input
# 1  
Old 09-04-2012
udev rule + script for setting webcam's mic as audio input

Hello,
whenever I plugin my webcam, I want to use its microphone instead of the one integrated in my laptop.
I therefore created a udev rule:
Code:
SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="0807", RUN+="/usr/local/bin/webcammic"

This rule works, I've tested it with a testscript (the testscript works when I plugin my webcam).

For changing the microphone I use the following script.
Code:
#!/bin/bash
echo "set-default-source alsa_input.usb-046d_0807_83CCA370-02-U0x46d0x807.analog-mono" | pacmd

This works as well if I execute it in my comand line like this:
Code:
jo@jo-P53E:~$ sh /usr/local/bin/webcammic
Welcome to PulseAudio! Use "help" for usage information.

However udev seems to execute as root and therefore the script in combination with the udev rule doesn't work (→ nothing happens when I plug in my webcam).
I therefore changed the script to:
Code:
#!/bin/bash
su jo -c "echo \"set-default-source alsa_input.usb-046d_0807_83CCA370-02-U0x46d0x807.analog-mono\" | pacmd"

But if I plugin the webcam, nothing happens. If I execute the script in the command line, I get the following error:
Code:
jo@jo-P53E:~$ sh /usr/local/bin/webcammic
Passwort: 
Welcome to PulseAudio! Use "help" for usage information.
>>> >>> Sessions still open, not unmounting
jo@jo-P53E:~$

Does anybody know what's wrong with my script or has any suggestions what to try else?
Thanks in advance!


Just for Information: I'm using Ubuntu 12.04
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Red Hat

Udev Rule TAG for identifying a local sas disk, non-scsi, non-fiber, non-iscsi

I need to add a VMware virtual disk to the 99-oracle-asmdevices.rules file but the OS is not assigning a WWID to the disk. It has been fdisk'd and a single partition created. What TAG inside the file needs to be added? the Program scsi-id does not work for some reason. latest patches... (0 Replies)
Discussion started by: mrmurdock
0 Replies

2. Slackware

Problems with audio recording in Audacity 2.0.5. Slackware64 14.1; Intel HD Audio.

I'm trying to record audio using Audacity 2.0.5 installed from SlackBuilds. My system is 64-bit Slackware 14.1 and a sound card is Intel HD Audio. I didn't change my sound system to OSS. (Default sound system in Slackware 14.1 is ALSA, isn't it?) First, I set Internal Microphone slider in KMix... (2 Replies)
Discussion started by: qzxcvbnm
2 Replies

3. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

4. Red Hat

set device mode permanently with udev rule

On a test server running CentOS 6, I try to permanently set the owner, group and mode of disk devices for use with a DB2 database. For this I created an udev rule file /etc/udev/rules.d/99-db2.rules: KERNEL=="sdb*", OWNER="db2usrl1", GROUP="db2adml1", MODE="0600" After a reboot, the owner and... (4 Replies)
Discussion started by: hergp
4 Replies

5. Shell Programming and Scripting

Simple BASH shell script to rename webcam jpg and copy into a new directory.

System: Ubuntu Intrepid Ibex I'm running webcamd as a sort of "security" program, but I need a script that will archive my webcam.jpg files. So, take the following file: /home/slag/www/webcam.jpg Rename it--preferably with a time stamp. Place it in say: /home/slag/www/history/ ... (4 Replies)
Discussion started by: robfindlay
4 Replies

6. UNIX Desktop Questions & Answers

webcam on FreeBSD

Hello, guys ! I'm using FreeBSD 6.0-RELEASE. Can anyone recomend me a good soft that I can use for video conferences ? I mean, something like Yahoo! Messenger on Windows. I want to make a video conference with a friend of mine, but I use FreeBSD and my friend is using Windows. So, any sugestions... (1 Reply)
Discussion started by: Sergiu-IT
1 Replies
Login or Register to Ask a Question