From owner-freebsd-questions@FreeBSD.ORG Sun Jun 5 02:33:16 2011 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0703B106566B for ; Sun, 5 Jun 2011 02:33:16 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (wonkity.com [67.158.26.137]) by mx1.freebsd.org (Postfix) with ESMTP id A05728FC0A for ; Sun, 5 Jun 2011 02:33:15 +0000 (UTC) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.14.4/8.14.4) with ESMTP id p552XEnw034905; Sat, 4 Jun 2011 20:33:14 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.14.4/8.14.4/Submit) with ESMTP id p552XEWV034902; Sat, 4 Jun 2011 20:33:14 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Sat, 4 Jun 2011 20:33:14 -0600 (MDT) From: Warren Block To: Scott Gasch In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-902635197-1433074227-1307241194=:34792" X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (wonkity.com [127.0.0.1]); Sat, 04 Jun 2011 20:33:14 -0600 (MDT) Cc: questions@freebsd.org Subject: Re: Usb printers take the same port deterministically? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jun 2011 02:33:16 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---902635197-1433074227-1307241194=:34792 Content-Type: TEXT/PLAIN; format=flowed; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT On Sat, 4 Jun 2011, Scott Gasch wrote: > Thanks, Warren.  Works great, mostly :) > I actually need the "unlpt*" device because of publishing the raw printers.  Hooking the attach/detach of those device names directly did not work.  Adding an action to the "ulpt" > device does work... but I then ran into the problem of pulling the number out of the $device variable to figure out what port just attached.  After some messing around (I tried to match > the device and serial variables) I gave up and just made two entries per printer: one for ulpt0 and one for ulpt1 (see below). "action" can be a whole script. Of course the quoting can get ugly. Here's what I use for a scanner. The backtick portion was from someone on the mailing lists. Can't recall who came up with it, but they deserve credit anyway: attach 20 { device-name "ugen[0-9].[0-9]"; match "vendor" "0x04b8"; match "product" "0x010a"; action "usb_devaddr=`echo $device-name | sed 's#^ugen##'` && \ chown root:saned /dev/usb/${usb_devaddr}.* && \ chmod 0660 /dev/usb/${usb_devaddr}.* && \ su saned -c '/usr/local/bin/scanbuttond \ -s /usr/local/etc/scanbuttond/buttonpressed.sh \ -S /usr/local/etc/scanbuttond/initscanner.sh \ -b /usr/local/lib/libscanbtnd-backend_epson.so'"; }; usb_devaddr is created by removing "ugen" from device-name. Then it sets owner and permissions on the device and runs scanbuttond as user "saned". > Just because I'm a pain, how does this work if you have two printers > from the same vendor?  Epson's product code 0x0009, for example, means > "high speed usb 2.0 printer".  So I'm guessing, really, that any epson > printer would match? Different models should have different product codes. Failing that, there might be other information available, like a model number or serial number. ---902635197-1433074227-1307241194=:34792--