From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Fri, 26 Aug 2005 01:01:45 +0000 Subject: Re: RUN rules to enable/disable printer queues Message-Id: <20050826010145.GB29729@vrfy.org> List-Id: References: <32962.66.92.218.83.1125017033.squirrel@mail.panix.com> In-Reply-To: <32962.66.92.218.83.1125017033.squirrel@mail.panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org On Thu, Aug 25, 2005 at 05:43:53PM -0700, Zack Weinberg wrote: > I have a USB printer which is turned off most of the time. I want to have > the computer automatically run "lpc start" and "lpc stop" on the relevant > print queue when the printer is turned on and off, respectively. >=20 > I tried to do this with this rule: >=20 > BUS=3D"usb", SYSFS{product}=3D"Lexmark Optra E310", SYSFS{serial}=3D"0101= 137", \ > SYMLINK=3D"lp_epson", RUN+=3D"/etc/udev/scripts/lpqueue.sh" >=20 > where lpqueue.sh is a little script I wrote that maps ACTION=ADd to lpc > start, and ACTION=3Dremove to lpc stop. >=20 > This correctly creates and deletes the lp_epson symlink, but lpqueue.sh is > only invoked on add events, not remove events, so it can only do half of > its job.=20 Use two rules, one for ACTION=3D"add" and one for "remove" if you want to name the device at the same time. The SYMLINK key prevents rule to be catch= ed by a "remove" cause it is only valid to _create_ a link - same for NAME, OW= NER, GROUP, MODE. > I believe that the rule *does* match on both add and remove, > because if it didn't match on remove, it wouldn't know to delete the > symlink udev has it's own database to remember the created nodes and symlinks. On remove everything that was created with add is removed without a explicit rule. Kay ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel