Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.