Separate keyboard layout for the lockscreen

It would be nice if Plasma allowed the user to chose the keyboard layout for the lockscreen independently of the layout(s) they use when logged-in.

I normally use the US QWERTY keyboard layout, but sometimes I have to switch to the layout for my native language. One of the most frequent and annoying issues I experience on my PC is that I tend to forget which layout is active when I type my password on the lockscreen. I am used to typing passwords in the US layout, and I don’t have any reason to use the other layout when logging in.

1 Like

I’ve got Thai and English layouts, I can press Alt_T to get English, or Alt_E to switch to Thai (just because that’s the accelerator that shows up when pressing Alt).

Not sure if this is an option for you, but in the “Behavior” Section of “Input Method” in System Settings there is the option to “Reset state on Focus”. If you set this to “All” the input method will reset to your main layout whenever you exit an input. I used to forget which layout was active myself all the time and got annoyed until I realized it’s much easier to just toggle the layout only when needed and have it automatically switch back afterwards.

Of course it’s probably not a good solution if you need to work in your native language for longer periods, but it totally fixed those problems for me.

1 Like

I don’t see that option. That’s probably because I use an older version of Plasma than you (6.3.6). However, I created an autostart script that fixes my problem:

#!/bin/sh

LOCK_KBD_LAYOUT=0


get_kbd_layout () {
    dbus-send --print-reply=literal --session \
        --dest=org.kde.keyboard /Layouts org.kde.KeyboardLayouts.getLayout \
        | sed -r "s/^   uint32 ([0-9]+)$/\1/"
}

set_kbd_layout () {
    dbus-send --session --type=method_call \
        --dest=org.kde.keyboard /Layouts org.kde.KeyboardLayouts.setLayout "uint32:$1"
}


PREV_KBD_LAYOUT=$(get_kbd_layout)
while [ -z $PREV_KBD_LAYOUT ]; do
    sleep 1
    PREV_KBD_LAYOUT=$(get_kbd_layout)
done


on_lock () {
    PREV_KBD_LAYOUT=$(get_kbd_layout)
    set_kbd_layout $LOCK_KBD_LAYOUT
}

on_unlock () {
    set_kbd_layout $PREV_KBD_LAYOUT
}


dbus-monitor \
    --session "type='signal',interface='org.freedesktop.ScreenSaver',path='/org/freedesktop/ScreenSaver'" \
| while read x; do
    case "$x" in
        "boolean true")  on_lock ;;
        "boolean false") on_unlock ;;
    esac
done

1 Like

To be fair, I’m not quite sure where this came from either. I’m on plasma 6.5.4, wayland and using fcitx5 for the input methods, so it could either be the plasma version, using x11 or fcitix4 which might be the issue.

Cool you found a solution, though!

1 Like