How to insert arbitrary unicode characters in kde keyboard shorctuts (send keyboard input)?
There's a systemic bug there. I have 2 workarounds, using xdotool
- install xdotool (
apt install xdotool
). - Create a custom shortcut with the script as action (New > Global Shortcut > Command/URL; Trigger: (your key combo)
Workaround #1 - sleep
Add a sleep
command before calling xdotool:
sleep 0.6
xdotool type "¯\\_(ツ)_/¯"
Woraround #2
Release the shortcut keys before calling xdotool:
xdotool keyup Super+n
xdotool type "¯\\_(ツ)_/¯"
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 a big, ugly and fragile hack, NOT a rock solid feature. YMMV.
-
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.