S
S
Slava Denisov2022-03-29 17:45:18
linux
Slava Denisov, 2022-03-29 17:45:18

How to make a script terminate on a keyboard shortcut in GNU/Linux?

How can I make the script stop when a key combination is defined?

I have this code:

var1=5
while [ $var1 -gt 0 ]
do
    xdotool mousemove 82 178 click --delay 220 --repeat 5 1
    xdotool mousemove 82 542 click --delay 220 --repeat 5 1
    xdotool mousemove 758 178 click --delay 220 --repeat 5 1
    xdotool mousemove 758 542 click --delay 220 --repeat 5 1
done

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rPman, 2022-03-29
@rPman

in the script itself in a loop (for example, for each new iteration), you check, for example, the presence of a certain file in / tmp, and when you run the script, delete this file, if there is
a key combination you need (in the standard DE settings), you set it to run your command bash -e touch /tmp/имя_файла, this command will create an empty specified file

X
xotkot, 2022-03-29
@xotkot

you can do this:
in the script itself, at the beginning, add the line:
echo $$ > /tmp/myscript.pid
now knowing the PID of the process of the running script, you can easily beat it with the command:
kill -9 $(cat /tmp/myscript.pid)
this command can be easily hung on a keyboard shortcut using the tools of the graphical shell you use.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question