Ubuntu – Xdotool does not work with xbindkeys

shortcut-keysxbindkeysxdotool

I want to use xdotool with xbindkeys but it does not work.

This is what I tried first:

"xdotool type a"
    m:0x1 + c:50
    Shift + Shift_L

this is not a duplicate as I have tried the solutions from other questions too:

"sleep 1 && xdotool type --delay 15 'a'"
    m:0x1 + c:50
    Shift + Shift_L

and

"xset r off; xdotool type --window 0 a; xset r on"
    m:0x1 + c:50
    Shift + Shift_L

I know that xbindkeys is working properly because I could execute echo test > /home/dalton/key.txt with it.

Best Answer

  • The default for xbindkeys is to catch Press event. It catches Shift + Shift_L then xdotool generate a key stroke. We get:

    Shift + Shift_L + a
    

    Similar to pressing: Shift_R+Shift_L+a (in this order)

  • These solutions worked for me:

    On Press event

    "xdotool keyup Shift_L keyup Shift_R key a keydown Shift_R"
        m:0x1 + c:50
        Shift + Shift_L
    

    On Release event

    "xdotool keyup Shift_R key a keydown Shift_R"
        Release + m:0x1 + c:50
        Release + Shift + Shift_L
    

    Also it is possible to use small pre-delay but that is not perfect method.

    Reference: xbindkeys + xdotool timing problems

Related Question