Skip to content

Instantly share code, notes, and snippets.

@jtmitchell
Created October 17, 2014 02:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtmitchell/d68c65996ee5d477a544 to your computer and use it in GitHub Desktop.
Save jtmitchell/d68c65996ee5d477a544 to your computer and use it in GitHub Desktop.
A script that reads a defaults file which has the pulseaudio device name, and your username in it. Use this to make your webcam the default input when you plug it in.
#!/bin/bash
#
# Setup the webcam mic for pulseaudio
#
WEBCAM_MIC=""
WEBCAM_USER=""
[ -r /etc/default/webcam-mic ] && source /etc/default/webcam-mic
[ -z "$WEBCAM_MIC" ] && exit 1
[ -z "$WEBCAM_USER" ] && exit 1
logger -t WEBCAM "set mic to $WEBCAM_MIC for $WEBCAM_USER"
(sleep 1s; su "$WEBCAM_USER" -c "pacmd set-default-source $WEBCAM_MIC")&
exit 0
@jtmitchell
Copy link
Author

Use this in conjunction with UDEV rules to set a USB webcam as the default input.
http://askubuntu.com/a/115575/44766

The config in /etc/default/webcam-mic is just so you can define the id for the webcam and your user name.
it just needs the 2 lines

WEBCAM_MIC="alsa_input.usb-Microsoft_Microsoft___LifeCam_VX-5500-02-VX5500.analog-mono"
WEBCAM_USER="james"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment