Paraphiliac Ostrich
Paraphiliac Ostrich

Reputation: 1290

udev rule not working when plugging in USB printer

I'm trying to run a script when a USB printer is plugged in on Ubuntu.

Based on this link, I tried to create a udev rule for every usb devices being plugged in.

As instructed I created the rule file with the following content

SUBSYSTEMS=="usb", KERNEL=="sd??", ACTION=="add", RUN+="/usr/local/bin/USB %k"

And then the script in the above path

#!/bin/bash
echo 'Hello World!' >>"/home/<username>/Desktop/udev.out"
exit

When I plug in my pen drive, indeed the udev.out file appears. Unfortunately, when I plug in a printer via USB, regardless of which door I use. the event simply doesn't trigger.

Is there anything I'm missing? or a different behaviour for different USB types?

Thanks in advance

I have also followed these steps to no avail

Upvotes: 0

Views: 1141

Answers (1)

David Grayson
David Grayson

Reputation: 87486

Roughly speaking, I think the KERNEL=="sd??" would only match devices that create a device whose name has the form /dev/sd*. I suspect your printer does not create such a device because it is a printer, not a disk drive. You should try removing the KERNEL=="sd??" part from your rule.

Upvotes: 1

Related Questions