udev rules for webcam

Fred Smith fredex at fcshome.stoneham.ma.us
Sat Nov 8 00:21:34 UTC 2014

On Fri, Nov 07, 2014 at 03:20:20PM -0500, Kevin Cummings wrote:
> On 11/06/2014 06:53 PM, Tom Horsley wrote:
> > On Thu, 6 Nov 2014 18:47:23 -0500
> > Fred Smith wrote:
> > 
> >> not finding anything on that, I hit on writing a udev rule for the
> >> USB device to make sure it appeared as a predictable /dev/video<x>.
> Did you try looking in /dev/v4l?  My laptop builtin webcam leaves
> entries in there.  The v4l directory has 2 sub-directories: by-id and
> by-path which contain entries for my webcam.

Hi Kev!

Yes, late yesterday I learned enough about udev to find the files
there, so I've modified my script to use those files to figure out
which /dev entry is the webcam I'm interested in. I suppose I could
use those files directly, too, and save a bit of computation.

an excerpt from the script that operates the camera:

  # figure out which /dev/video<x> entry is the camera we want.
  foo=`ls -l --dereference-command-line-symlink-to-dir /dev/v4l/by-id/usb-046d_0825*`
  devnode=`echo $foo | sed -e "s;^.*> \.\./\.\./;;"`
  # then snap it
  ${progdir}/fswebcam --png 9 -d /dev/${devnode} -r 800x600 -F 2 --save ${day}/img-%Y%m%d-%H%M%S.png

---- Fred Smith -- fredex at fcshome.stoneham.ma.us -----------------------------
                    The Lord detests the way of the wicked 
                  but he loves those who pursue righteousness.
----------------------------- Proverbs 15:9 (niv) -----------------------------

More information about the users mailing list