You are not logged in.
Hi,
On my Arch box I would like to have a bash script run every time a certain application is opened from the menu. I would prefer a delay of a 5 - 10 seconds after the program opens if that is possible. Could someone please let me know if and how I can achieve this?
Offline
Easy, if your PATH is set up right, so /home/youruser/bin is first in your PATH.
Just have a script in ~/bin/ named the same as your program, which does an exec at the end, e.g.:
#!/bin/bash
export __GL_SYNC_TO_VBLANK=0
exec nice -n -3 /usr/bin/glxgearsOffline
Problem is, OP wants the "meat" of his script to run after the program, which would mean putting it after the exec. But AFAIK, anything after the exec will be ignored. You could call another script to run in the background before the exec, but that seems hackish.
Last edited by alphaniner (2013-04-10 14:57:01)
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
#!/bin/bash
/usr/bin/$@ &
sleep 5
#do something elseFill in the "do something else" part.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks! Another issue is that this is a program often invoked by a link in the browser as a default action which seems to complicate matters a little.
Offline
Thanks! Another issue is that this is a program often invoked by a link in the browser as a default action which seems to complicate matters a little.
That's too bad. What do you plan to do about that ?
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
Details are always better than vagueness, so how about naming the "certain application" and posting the script you want to run?
Offline
Not only the "certain application", but knowing what browser this is, and how it has been configured to launch anything would be helpful. Many browsers use mime-type info to determine what program/script to launch.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Maybe inotfiy (say, incron -- hook the script on IN_OPEN "certain application" binary: wait 5s, check if application is running, as IN_OPEN does not necesssarily mean execution) or auditd (pro: can be hooked to actual execution, con: all it can do is log, so a log-watcher would be needed to do something more elaborate).
Offline