The goal of the script is the following:
Whenever I leave my house, my wife comes to my computer to check her mails (She has two computers of her own but they have a dangerous operating system, so they have been banned from the internet).
She shuts down qbittorrent so as to download all her mails, and she forgets to execute it again on 98% of the times. End result: my computer is sometimes turned on for 10 hours doing absolutely nothing.
I had therefore two choices: a) get on my wife's nerves until she gets the problem or b) write a bash script.
If you are married, you will understand that bash scripts are easier to deal with than spouses.
Ergo, I wrote the following script:
Code:
#!/bin/bash -x
while true ; do
TH=$(pgrep thunder)
if [ $TH != [0] ] ; then
sleep 300s
else
if [ -z "$(pgrep qbittorrent)" ] ; then
kdialog --yesnocancel "QBitTorrent no se está ejecutando, ¿shall I?"
ANSWER=$?
if [ $ANSWER = 2 ] ; then
exit
elif [ $ANSWER = 0 ] ; then
qbittorrent
elif [ $ANSWER = 1 ] ; then
echo
else
qbitorrent
fi
fi
fi
sleep 10s
done
I don't know how to make it wait for, say, 15 seconds, and, if no input from kdialog is received, run qbittorrent.
Any help?