I want to send a keyboard / character (to the active window).
This never did what I intended. No input was sent to any application (qt/gtk/console).
**steps (as per the documentation) **
- open "custom shortcuts"
- create new > global shortcut > keyboard input
- assign a shortcut key
- write the characters to be sent
- Apply / ok.
background:
- Assigning shortcuts to specific functions in specific apps -> work
- I created this bug report at bugs.kde.org
- Kubuntu 20.04
- Plasma 5.18
- EN+HE keyboard layouts
Semi-successful workaround using xdotool:
- install xdtool
- create a script that sends intended keystrokes (
xdotool type text
) - in Plasma, create a custom COMMAND (instead of keyboard input)
- This sometime works, usually not, unknown factors.
- xdotool works by itself, i.e. from console or script, e.g. "sleep 10 ; xdotool type stuff" then switch window.
- At best, pressing the key-combo did "awkward" things, like moving windows around, or sending tab key to the active window.
I'm at loss.
I'm looking either for a solution, a workaround, or explanation.
BTW: Is it mandatory to restart after every change in custom keys?
There's a systemic bug there. I have 2 workarounds, using xdotool
apt install xdotool
).Workaround #1 - sleep
Add a
sleep
command before calling xdotool:Woraround #2
Release the shortcut keys before calling xdotool:
notes:
in my case, the script can be called by multiple shortcut keys. So I call
xdotool keyup
multiple time, for each key-combo.use double quotes. Don't ask me why. Not required for a single key.
Escape the single backslash, i.e.
"¯\\_(ツ)_/¯"
The reason for the workarounds, is that the key combo is using the meta key. If the meta key is pressed while the unicode code is sent to the current app, then Plasma is sending garbage to the current app / to the window management. With a small delay, it doesn't happen.
xdotool sends it to the currently active window by default.
This is obviously an ugly and fragile hack, NOT a rock solid feature.
There are numerous KDE bugs around this feature, one of them is about reusing old shortcuts. If it doesn't work immediately, I recommend logout / restart.