6

My system has to auto-mount USB devices; how can I be notified when a USB device is plugged in? Where can I read more about this subject?

I would like to handle this problem via C or a shell script.

  • 1
    And what about specifically "user space" options? I want my own shell script to run A) when a drive becomes available (e.g. auto-mount) and B) when a drive is about to become unavailable (e.g. "unmount" via gvfs or a gui file manager. – user29020 Apr 16 '14 at 14:31
5

Udev support running external programs

KERNEL=="sdb", RUN+="/usr/bin/my_program"
  • Tip: You can use github.com/mgorny/sw-notify-send for that external program. – lkraav May 19 '11 at 16:18
  • 3
    @lkraav: FWIW, You should be able to edit this answer... – Shog9 May 19 '11 at 19:08
  • 1
    Don't udev RUN commands run as root? Is there a way to set up a script to run from an unprivileged user space? Thanks. – user29020 Apr 16 '14 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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