Execute on USB insert

From ArchWiki
Revision as of 20:21, 14 December 2010 by Gogodidi (talk | contribs) (Installation)
Jump to navigation Jump to search

Suppose you want to execute a certain program on the insertion of a usb dongle. Personally, I added this feature because I was getting frustrated with the computer locking up and all keyboard and mouse input was lost (The sysrq keys were not working).

There is an added security feature so that only dongles with the correct key can run the program.


Put a copy of the Template:Filename script (given below) in your path.

Add the following line to your udev USB mount rule (Modify to fit your configuration):

 ACTION=="add", RUN+="/usr/bin/exdongle run /media/%k-%E{dir_name}"

Run the configuration option, for example


This sets the configuration to a random key value (only programs with the correct keys can be run on the computer), and the runtime priority to -10.

Setting up a USB dongle

First, write a script that you want to run when the dongle is inserted.

For example:


Now run the new option:

 exdongle new <Dongle mount point> test.sh

Now, whenever you insert the dongle, a root shell will be opened under the X server running on display :0. This may be useful for some administrative purposes.


There may be security issues with this, but it is probably best used for a personal computer.

exdongle script