I would like it to always switch to US English independent of whatever is set in the user session under X / Wayland before. Once it goes to a lock (screensaver) or login screen, switch back to US English.
Assuming that, your system is using systemd for the system initialisation and, that systemd is using SDDM as the default Display Manager then,
- The default (system) keyboard layout is defined by the system configuration file â/etc/vconsole.confâ.
Depending on which Linux distribution youâre using, there may or, may not, be system tools available to assist with the setup o the default system keyboard layout.
Iâm definitely not an expert on keyboard layouts, but just one other note here - the lock screen runs within the user session, and is separate from the login screen. The former is part of Plasma (kscreenlocker), while the latter is part of SDDM.
There would probably be different steps required to force a different keyboard layout within a userâs session if the lock screen is active, than trying to force a different layout just for SDDM.
OK, letâs just talk about Lock screen, Login screen always defaults to the first keyboard language setting anyway.
I need something like this:
if lock_screen==true then
keyboard_layout=US
end
In other words, the system has a default physical keyboard layout which, a KDE Plasma session user can change to whatever that user wants â for that particular session and, subsequent sessions when that user logs out and then logs back in again.
And, when that user locks their session, the keyboard layout is that layout the user chose while the session was active.
What happens if a new session is started for another user?
-
AFAICS, itâs not possible to start a new session instance for a user who is already has an active KDE Plasma session executing â at least thatâs what this Plasma 5 session is indicating â attempting to start a new session instance simply drops me back into the already running session âŚ.
-
But, I wasnât able to determine if, the attempt to start a new Plasma session uses the userâs keyboard layout or, the systemâs keyboard layout.
That is fine:
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
BACKSPACE="guess"
however that does not change anything on lockscreen. I need a way to programatically switch to that layout on a Plasma 6 lockscreen.
Single-user computer, so no need for complicated setups.
Iâll have to investigate this script:
dbus-monitor --session "type='signal',interface='org.kde.screensaver'"
signal time=1744212016.289974 sender=org.freedesktop.DBus -> destination=:1.812 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
string ":1.812"
signal time=1744212016.290021 sender=org.freedesktop.DBus -> destination=:1.812 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
string ":1.812"
signal time=1744212017.756886 sender=:1.20 -> destination=(null destination) serial=37304 path=/ScreenSaver; interface=org.kde.screensaver; member=AboutToLock
signal time=1744212017.756911 sender=:1.20 -> destination=(null destination) serial=37305 path=/org/freedesktop/ScreenSaver; interface=org.kde.screensaver; member=AboutToLock
So I guess Iâll have to create a script to run on âAboutToLockâ or on locked:
Also:
Yeah, this works well for monitoring:
dbus-monitor --session "type='signal',interface='org.kde.screensaver',path='/ScreenSaver',member='AboutToLock'" |grep -i abouttolock
signal time=1744213665.803183 sender=:1.20 -> destination=(null destination) serial=45292 path=/ScreenSaver; interface=org.kde.screensaver; member=AboutToLock
and this for changing the layout:
qdbus6 org.kde.keyboard /Layouts setLayout 0
Now I just have to put it together ![]()
So running this seems to be working:
#!/bin/bash
dbus-monitor --profile --session "type='signal',interface='org.kde.screensaver',path='/ScreenSaver',member='AboutToLock'" |
while read -r line; do
qdbus6 org.kde.keyboard /Layouts setLayout 0
#echo "switching"
done
Although I am not sure why dbus-monitor ignores the member requirement and displays also information such as (that nobody asked for):
sig 1744216116.433048 2 org.freedesktop.DBus :1.5147 /org/freedesktop/DBus org.freedesktop.DBus NameAcquired
sig 1744216116.433285 4 org.freedesktop.DBus :1.5147 /org/freedesktop/DBus org.freedesktop.DBus NameLost
I have also documented the solution with further explanation here:
for the user session default keyboard layout and variant you can look at
/etc/X11/xorg.conf.d/00-keyboard.conf
and it should always come back to that after a reboot, but if you change it up during a user session and then the screen locks, then your screen lock will be using whatever keyboard layout was active at the time.
the only way i can see to control the layout is to script your own screen locking routine that calls setxkbmap to change the layout to âusâ before locking the screen
Thank you for coming 9 months later in a thread with the posted solution just to repeat something weakly related. Not.
my bad for not paying attention