Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I am using libusb to contact with a printer. And I am writing a rule for udev to remove the printer when it is disconnected. I use symlink to indicate the device. But when removing, the rule is not triggered. What should I do?

ATTRS{manufacturer}=="Zebra Technologies", ACTION=="add", RUN+="/usr/local/bin/reinitZebra.sh", SYMLINK+="usblp%k"
SYMLINK=="usblp%k", ACTION=="remove", RUN+="/usr/local/bin/reinitZebra.sh"
share|improve this question

1 Answer 1

  • %k (variables) are not to be used in the rule matching condition.

    String substitutions

    When writing rules which will potentially handle multiple similar devices, udev's printf-like string substitution operators are very useful. You can simply include these operators in any assignments your rule makes, and udev will evaluate them when they are executed.

    Source: Writing udev rules by Daniel Drake (dsd)

  • Use directly same add condition (you have chosen a long path):

    ATTRS{manufacturer}=="Zebra Technologies", ACTION=="remove", RUN+="/usr/local/bin/reinitZebra.sh"
    
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.