Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm not even sure if this is possible or not but this is what I'm trying to do: Everytime a user opens a file through double clicking I want to launch a script which does a few things depending upon what kinda file it is or what directory it's in. How do I launch a script when the user opens a file?

share|improve this question
up vote 4 down vote accepted

This is possible to do.

You will need to watch the file system using inotify-tools to check for events (such as files being opened) and then handle them as required (such as running a shell script).

You will need to know about incron too.

There are some examples on the incron site, something like this may be a starting point for you:

Example: You need to run program abc with the full file path as an argument every time a file is changed in /var/mail. One of the solutions follows:

/var/mail IN_CLOSE_WRITE abc $@/$#

share|improve this answer
rtn: Have a read up and if you get stuck on specifics post a new question. – Richard Holloway Sep 19 '11 at 9:04
cool... looks promising. I'll give it a shot. Thanks – rtn Sep 20 '11 at 5:02

Your Answer


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.