I need a shell script, loaded at start-up, running in the background, that will listen out to see if process A is running. If process A is running, then I need the shell script to kill process B for the duration that process A is running. Then, if process A stops running, the shell script needs to restart process B
So, logically, I guess:
if process A is running
stop process B
else
start process B
However, I need this shell script to be available to make the above “decisions” on a continual basis. In other words, if process A has been run during a session and the shell script has carried out its commands (closed process B or started process B), if I decide to run process A again later on in a session, I need this shell script to be able to continually run it’s commands (to stop or start process B) accordingly.
So, I am guessing some kind of loop
process A is defined as: agisoft-photoscan.sh (this a shell script that loads a virtualbox xp vm in full screen with agisoft photoscan open and ready to go)
process B is defined as: compton
In plain English, if this VM is running Compton needs to be switched off and if this VM is not running, Compton needs to be switched on.
At the moment, I am manually switching Compton on and off when I need to. but, it would be really nice to automate it.
Could really do with some help here in terms of how to actually write this script out.
Cheers folks