0

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?

Egene
  • 88
  • Not sure if I understand the story completely, but it seems another case of this http://askubuntu.com/questions/872695/how-to-create-a-shortcut-that-executes-an-xdotool-command-to-simulate-a-key-pres/872698#872698 – Jacob Vlijm Apr 08 '17 at 13:16
  • Thank you for your suggestion, but sadly its not it. If I add the "sleep 1 &&" to the xbindkeys trigger, the result is exactly the same as before except it sleeps for 1 second before running my script – Egene Apr 08 '17 at 19:01

0 Answers0