I have a broken key on my keyboard, The dot "." to be specific. It behaves very oddly, about 7/10 times the keyboard types a double dot ".." when clicked once. I use xbindkeys to intercept when the dot key is pressed and trigger my bash script to start. The bash script I wrote checks how many instances of it are running and only types the "." once.
#!/bin/bash
let "target=2"
curr=$(ps -A | grep 'dot-writer.sh' | wc -l)
if [ "$curr" -eq "$target" ]
then
numlockx on
xdotool key KP_Delete
sleep 0.1
fi
As you can see from the script I am not actually typing the "." key with xdotool, but instead, I am enabling Numlock and typing the other"." on my keyboard located on the keypad on the same button as delete.
As you can probably guess this is not a perfect solution because those two keys do not exactly act the exact same way 100% of the time.
I tried telling xdotool to type the "." as a Unicode character
xdotool key U002E
I tried telling xdotool to type the "." as a string generated by Bash
xdotool type $'.'
I tried telling xdotool to type the "." as a string generated by Bash containing the Unicode character "."
xdotool type $'\u002E'
None of this seems to work as it get intercepted as if the dot key has been pressed by xbindkeys and triggers the same script again and again.
Is there anything I can do? Can I use some other tool to imitate a key press?