Difference between revisions of "Execute on USB insert"

From ArchWiki
Jump to: navigation, search
m (add tag i18n)
m (Add section on disabling trackpad on external mouse connection)
Line 214: Line 214:
== Disable Trackpad on Mouse Connection ==
Adapted from [http://www.howtoforge.com/how-to-auto-disable-the-touchpad-when-the-mouse-is-plugged-in-fedora-13 Howto Forge].
== Notes ==
== Notes ==

Revision as of 00:06, 13 February 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

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 [[Execute_on_usb_insert#exdongle_script|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, and it is probably best used only on a personal computer.

exdongle script


Disable Trackpad on Mouse Connection

Adapted from Howto Forge.


Some notes:

  • The programs/scripts used should be self contained, the only file treated is the one passed.