I have enabled 2 keyboard layouts. KDE Connect with a german keyboard. sends the wrong keys when using en layout
So I want a command to toggle the available keyboard layouts through KDE Connect. Not a keyboard shortcut, but a command.
I could find nothing, only X11 stuff years ago
Using Plasma 6, Wayland
Iâm confused - does Ctrl+Shift, or Alt+CapsLock not work on a German layout?
For some reason people mix âcommandâ and âkeyboard shortcutâ.
I edited the post
I assumed the REASON for this was that the keyboard layout changedâŚ
So now we have a situation where you wish to use KDE Connect to change the language for your desktop keyboard remotely?
kcmshell6 kcm_keyboard
will pull up the relevant setting.
The config file is ~/.config/kxxbrc and contains a LayoutList.
For X11 setxkbmap -layout (us | th)
would do the trick.
Sadly Wayland lacks a few key functions - so I reverted to X11 already.
It does seem strange that youâd refuse mention of a keyboard shortcut to change keyboard layout - when itâs useless without having a keyboard.
Maybe my brain isnât up to this task 
You likely never used KDE connect and tried to control your desktop through a phone keyboard 
But thx, I will try that command!
So in Plasma there are at least two quick ways to change the current keyboard layout, a keyboard shortcut and a click on the Keyboard Layout widget
Finding if the widget calls a D-Bus method we can use
By running clear;dbus-monitor --session --monitor | grep -iE 'keyb'
we can see there is a dbus method that the widget seems to be calling
method call time=1736761239.718680 sender=:1.81013 -> destination=org.kde.keyboard serial=30984 path=/Layouts; interface=org.kde.KeyboardLayouts; member=switchToNextLayout
signal time=1736761239.718889 sender=:1.13 -> destination=(null destination) serial=172313 path=/Layouts; interface=org.kde.KeyboardLayouts; member=layoutChanged
string "keyboard-layout"
Now we try to call it ourselves⌠it works
qdbus6 org.kde.keyboard /Layouts org.kde.KeyboardLayouts.switchToNextLayout
Finding if the shortcut calls a D-Bus method we can use
By running again clear;dbus-monitor --session --monitor | grep -iE 'keyb'
we can see there is a dbus method that the keyboard shortcut calls (or any other keyboard shortcut for that matter, found about that when working in a widget to call shortcuts from the panel)
signal time=1736761838.229075 sender=:1.13 -> destination=(null destination) serial=184476 path=/component/KDE_Keyboard_Layout_Switcher; interface=org.kde.kglobalaccel.Component; member=globalShortcutPressed
string "KDE Keyboard Layout Switcher"
string "Switch to Next Keyboard Layout"
Now we try to call it ourselves⌠it also works
qdbus6 org.kde.kglobalaccel /component/KDE_Keyboard_Layout_Switcher org.kde.kglobalaccel.Component.invokeShortcut "Switch to Next Keyboard Layout"
There are also other shortcuts but I havenât tried those
qdbus6 org.kde.kglobalaccel /component/KDE_Keyboard_Layout_Switcher org.kde.kglobalaccel.Component.shortcutNames
3 Likes
I use KDE Connect - but Iâll admit I never bothered using the remote mouse or keyboard function, I hate typing on the phone.
However, qdbus is the way to go, and kudos to @luisbocanegra:
qdbus6 org.kde.keyboard /Layouts org.kde.KeyboardLayouts.switchToNextLayout
does work.
kenning
8
thanks, great trick!
On Fedora it is
qdbus-qt6 org.kde.keyboard /Layouts org.kde.KeyboardLayouts.switchToNextLayout