How do I run a script when a program starts/ends?

Specifically, I made a script to toggle my touchpad/trackpoint on and off and I want to use it to turn inputs off when I start GIMP and to turn them on again when I stop it.


if [ $1 = "on" ]
    echo "Turning inputs on"
    xinput enable 15
    xinput enable 13
elif [ $1 = "off" ]
    echo "Turning inputs off"
    xinput disable 15
    xinput disable 13

This is my script (it was suggested that I include it)


You can write a script and include your command/s to turn on and off the touch-pad before and after starting the gimp program:

commands to turn on touch-pad && gimp
commands to turn off touch-pad 

By executing this script the touch-pad will turn on before running the gimp and when you close the program touch-pad will turn off.

  • I'll do this if we can't figure out a solution Nov 3 '13 at 0:48

Can you share your script in order to understand what is going on?

Also a side-tip. All UNIX programs get configuration through an rc file. You could try and see what options '$HOME/.gimp/gimprc' takes.

A second approach would be a wrapper around your Gimp launcher, which depends on the DE or WM you are using. Provide more info and someone might come up with a clear-cut solution.


The proper way to do this is to use an alias:

Since I wanted to turn some stuff off when gimp starts and on when gimp ends, I would execute

alias gimp="toggle-input off; gimp; toggle-input on"

Now, when gimp is executed, it will first execute toggle-input off, then it will run gimp, then after gimp is finished being used it will execute toggle-input on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.