I have a script on my Fedora PC that I want to run only while Firefox is active. I want to find a way to monitor the PC for Firefox's status.
Once Firefox starts, I want the script to start. When Firefox is closed, I want the script to stop. If Firefox is reopened in the same session, I want the script to run again, and repeat the process as many times as necessary.
Let's call the script "bash_script.sh". For example:
#!/bin/sh
Start monitoring FF status
When FF starts, do something
When FF is closed, stop doing it and continue monitoring FF status
So I have the following questions:
- Is there a way to achieve this with a bash script? Can you please give me an example?
- Should I change the permissions to 777 and put this script on crontab?
- If yes, what syntax should I use? If no, how else can I achieve that process?
I am a complete beginner with bash scripting and I have no idea where to start! Apologies if this is a very easy question.