I tried to use dxhd with xdotool to prepend each key with Ctrl+G, then type that key, and hit another key, like so


# @{a-z}
xdotool key ctrl+g
xdotool type {a-z}
sleep 1
xdotool key Tab

What I'm trying to accomplish is when I type any character, a for example, it will act as if I hit Ctrl+G, then type an a, and wait for 1 second, and then hit Tab.

The problem is when I try to type a, it would actually send Ctrl+G, then an a, which would trigger another sequence recursively (another Ctrl+G -> a -> Ctrl+G -> a -> ...).

Is there a correct way of doing this?

1 Answer 1


There doesn't appear to be a native way to avoid recursion using dxhd, but it can be done with sxhkd using the following configuration:

    pkill -USR2 -x sxhkd; xdotool key ctrl+g key {a-z} sleep 1 key Tab; pkill -USR2 -x sxhkd

The first and last commands send sxhkd the SIGUSR2 signal, which toggles the grab state of all its bindings. This allows us to use the bound key in between without causing recursion.

(The xdotool command has also been compressed into one line using its built-in command chaining, just to make the line shorter; the original commands separated by ; would also work. Unfortunately, sxhkd does not support multi-line commands.)

  • 1
    Thank you sir, I switched to sxhkd and that works.
    – LeafLover
    Nov 14, 2021 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .