7

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
  • 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. Commented Apr 16, 2014 at 14:31

1 Answer 1

5

Udev support running external programs

KERNEL=="sdb", RUN+="/usr/bin/my_program" 
3
  • Tip: You can use github.com/mgorny/sw-notify-send for that external program. Commented May 19, 2011 at 16:18
  • 3
    @lkraav: FWIW, You should be able to edit this answer... Commented May 19, 2011 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. Commented Apr 16, 2014 at 14:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.