Answer the question
In order to leave comments, you need to log in
How to exit the script on Esc?
We have a script that rotates the display of random pictures and quotes in a cycle with an interval of 5 seconds.
How to end it with a single button press, without taking up an extra HOTKEY under the killall script, (preferably by Esc )
you need something a la an event handler in JS, i.e. if the script works and the treasured button was pressed, then we kill
Answer the question
In order to leave comments, you need to log in
I do this to myself, this is what is spinning in the cycle, and by pressing any button, the process is interrupted.
if read -r -n 1 -t 5 -p ""; then
echo "Process was cancel"
break
fi
Something like
while true; do
read input
if ["$input" = "a"]; then
echo "hello world"
fi
done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question