Sponsored Content
Operating Systems Linux udev rule + script for setting webcam's mic as audio input Post 302696329 by MojoDodo on Tuesday 4th of September 2012 08:02:50 PM
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
 

6 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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
DH_INSTALLUDEV(1)						     Debhelper							 DH_INSTALLUDEV(1)

NAME
dh_installudev - install udev rules files SYNOPSIS
dh_installudev [debhelperoptions] [-n] [--name=name] [--priority=priority] DESCRIPTION
dh_installudev is a debhelper program that is responsible for installing udev rules files. Code is added to the preinst and postinst to handle the upgrade from the old udev rules file location. FILES
debian/package.udev Installed into lib/udev/rules.d/ in the package build directory. OPTIONS
--name=name When this parameter is used, dh_installudev looks for and installs files named debian/package.name.udev instead of the usual debian/package.udev. --priority=priority Sets the priority string of the rules.d symlink. Default is 40. -n, --noscripts Do not modify preinst/postinst scripts. NOTES
Note that this command is not idempotent. dh_prep(1) should be called between invocations of this command. Otherwise, it may cause multiple instances of the same text to be added to maintainer scripts. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 8.9.0ubuntu2.1 2012-06-12 DH_INSTALLUDEV(1)
All times are GMT -4. The time now is 10:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy