KDE: a lot of bugs. Looking for users who use KDE

Sorry for the delay. Here are the instructions. As a reminder: the concept here is that you get distinct shortcuts for each keyboard layout and no indicator icon, rather than a single toggle shortcut plus an indicator icon for visual feedback. Importantly, these shortcuts can work reliably, and it doesn’t hurt to press the right one again at any time (as long as the intended qube’s window is in focus) to make sure you have the right layout on. So I think it’s a good way to be switching layouts.

Install the sxhkd package in the desired templates the way you normally install software in Qubes OS.

In each existing qube where you want to enable keyboard shortcuts for switching languages you need to add two files (recreate the directory structure). To configure keyboard shortcuts and specify keyboard layouts you need /home/user/.config/sxhkd/sxhkdrc. Check sxhkd’s man page for configuration syntax. My example file below is a bit complicated so the shortcuts wouldn’t interfere with other common shortcuts involving the same keys, and to make them work regardless of key order. If the documentation is not enough for some complications and corner cases like this, use search/chat bots/experimentation. Change the language es to whatever language and keyboard layout you need (check setxkbmap’s documentation for that, if needed) and make sure you keep the ,us part at the end if the letters are much different, otherwise common shortcuts involving letter keys will break.
Example sxhkdrc file (mind the whitespaces):

alt + ~Shift_L
    setxkbmap -layout "es,us"
shift + ~Alt_L
    setxkbmap -layout "es,us"
alt + ~Control_L
    setxkbmap -layout "us"
control + ~Alt_L
    setxkbmap -layout "us"

To automatically start listening for the hotkey each time the qube boots you can create /home/user/.config/autostart/sxhkd.desktop:

[Desktop Entry]
Name=sxhkd
Comment=Simple X hotkey daemon
Exec=/usr/bin/sxhkd
Terminal=false
Type=Application

When you configure one qube and make sure it works correctly with no bugs you can copy the files to the other qubes. You can also make it so all new qubes you create based on a certain template inherit these files in the correct directories, by placing the files at /etc/skel/.config/sxhkd/sxhkdrc and /etc/skel/.config/autostart/sxhkd.desktop in the template.

There are different ways to implement something like this without sxhkd and instead using KDE’s own global shortcuts (which is less flexible than sxhkd in the keyboard combinations it accepts) + bash scripts in dom0. The chores needed per qube can be removed.

1 Like