Skip to content

Instantly share code, notes, and snippets.

@stevenharradine
Last active June 11, 2017 21:04
Show Gist options
  • Save stevenharradine/192de921b0901c24510446e1bc4a2bba to your computer and use it in GitHub Desktop.
Save stevenharradine/192de921b0901c24510446e1bc4a2bba to your computer and use it in GitHub Desktop.
Make default camera /dev/video0 point to the "best" camera present.
#!/bin/bash
# Make default camera /dev/video0 point to the "best" camera present.
# Source: https://askubuntu.com/questions/396952/how-to-change-the-default-webcam-changing-dfaults-in-multimedia-selctor-not-wor
# Date: 20170611@21:02UTC
# By: Jason Eisner (https://github.com/jeisner)
if [ -h /dev/video0 ]; then
sudo rm /dev/video0 # not first run: remove our old symlink
elif [ -e /dev/video0 ]; then
sudo mv /dev/video0 /dev/video0.original # first run: rename original video0
fi
if [ -e /dev/video1 ]; then
sudo ln -s /dev/video1 /dev/video0 # symlink to video1 since it exists
echo "Set default camera /dev/video0 --> external camera /dev/video1"
elif [ -e /dev/video0.original ]; then # symlink to video0.original otherwise
sudo ln -s /dev/video0.original /dev/video0
echo "Set default camera /dev/video0 --> integrated camera /dev/video0.original"
else
echo "Sorry, does this machine have no camera devices?"
ls -l /dev/video*
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment