The Smell of Molten Projects in the Morning

Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.

The New Hotness

  • Udev rule to create /dev/scanner

    For some unknown reason, Kubuntu 8.04 doesn’t create a /dev/scanner link while it’s figuring out all the SCSI devices. I wanted to make the link sort of generic for any scanner that I might plug in, but I had to settle for a unique udev match.

    The scanner popped out of udev as /dev/sg5 this time and

    udevinfo --query=all --attribute-walk --name=/dev/sg5
    

    emits this useful chunk:

    looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:05:05.0/host4/target4:0:2/4:0:2:0':
        KERNELS=="4:0:2:0"
        SUBSYSTEMS=="scsi"
        DRIVERS==""
        ATTRS{device_blocked}=="0"
        ATTRS{type}=="3"
        ATTRS{scsi_level}=="3"
        ATTRS{vendor}=="HP      "
        ATTRS{model}=="C7670A          "
        ATTRS{rev}=="3945"
        ATTRS{state}=="running"
        ATTRS{timeout}=="0"
        ATTRS{iocounterbits}=="32"
        ATTRS{iorequest_cnt}=="0x656"
        ATTRS{iodone_cnt}=="0x656"
        ATTRS{ioerr_cnt}=="0x2"
        ATTRS{modalias}=="scsi:t-0x03"
        ATTRS{evt_media_change}=="0"
        ATTRS{queue_depth}=="2"
        ATTRS{queue_type}=="none"
    

    Plucking the readable bits out produces this stanza for/etc/udev/rules.d/60-symlinks.rules

    #-- hack to create /dev/scanner
    SUBSYSTEMS=="scsi", ATTRS{vendor}=="HP", ATTRS{model}=="C7670A", SYMLINK+="scanner"
    

    Then you can use that to fire up xsane thusly:

    sane hp:/dev/scanner

    With that in hand, edit GIMP’s ~/.gimp-whatever/menurc and ~/.gimp-whatever/pluginrc to replace sg5 (or whatever) with scanner.

    Works like a champ…

    The straight dope on writing udev rules is at http://www.reactivated.net/writing_udev_rules.html

    Memo to self: there’s got to be a way to make this generic, perhaps by piggybacking on whatever udev stanza assigns the scanner group to that /dev/sg? device.

    Update: make sure you’re in the scanner group

    sudo usermod -a -G scanner username