I would like to detect if a key is being pressed when running a script. I have the following script:#!/bin/bashsleep 0.5xte 'str sometext'I run this script using a shortcut to paste sometext where I'm at in kde. I used a sleep 0.5 here because the script itself is run with a shortcut that uses ctrl and alt. If the sleep 0.5 is omitted, the result is that ctrl+s, ctrl+o, etc... is sent. I think the solution would be to add some bussy wait at the beginning that would block untill no keys are being pressed. How can I get this to work in the script?
detect if key is pressed from script
scripting;x11;keyboard;xte
Since you are using xte anyways, why not release the keys with xte? Something along the linesxte keyup Control_Lxte keyup l(assuming your shortcut is ctrl-l).