This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Can't switch to another layout

Tags: None
(comma "," separated)
rednull
Registered Member
Posts
28
Karma
0
OS

Can't switch to another layout

Sun Feb 02, 2020 9:45 am
Hello. Why after command "setxkbmap us" I can't switch to another layout by global hotkeys (Ctrl+Alt) until new settings in "Keyboard - System Settings Module" hasn't been applied (for example, change any setting, then press Apply, then revert changes and press Apply again) or session hasn't been restarted?

Any ideas how to avoid that?

Thanks!
User avatar
Mamarok
Manager
Posts
6071
Karma
16
OS

Re: Can't switch to another layout

Sun Feb 02, 2020 3:35 pm
Instead of using the command line keyboard layout switching, why don't you just install the layouts in the system settings and use the Systray button to switch?


Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ...
rednull
Registered Member
Posts
28
Karma
0
OS

Re: Can't switch to another layout

Tue Feb 04, 2020 8:37 am
Mamarok wrote:Instead of using the command line keyboard layout switching, why don't you just install the layouts in the system settings and use the Systray button to switch?


Hello.
Yes, all layouts are already setted up in system settings.

But sometimes I need to switch from currently selected layout to US automatically.
For example, before launching some programs with guaranted US layout.

So is it possible?
Maybe there is another way, without calling setxkbmap (for examples through dbus or something else)?
User avatar
Mamarok
Manager
Posts
6071
Karma
16
OS

Re: Can't switch to another layout

Tue Feb 04, 2020 5:34 pm
You can do that with the Systray Button very easily, only one click needed, unless you have more than two keyboard layouts. I personally have 4, so I am never more than 3 clicks away from the US layout. nd it is definitely easier than switching to the konsole and type text.

In the System Settings -> Hardware -> Input Devices -> Keyboard -> Layouts folder, click on "Show Layout Indicator"
Below in the Layouts, assign a label to each of the layouts

Do not use the "Flag" or "label on flag" option, as the current monochrome systray doesn't show this correctly, especially not in Latte Dock.


Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ...
rednull
Registered Member
Posts
28
Karma
0
OS

Re: Can't switch to another layout

Thu Feb 06, 2020 2:44 pm
Mamarok wrote:You can do that with the Systray Button very easily, only one click needed, unless you have more than two keyboard layouts. I personally have 4, so I am never more than 3 clicks away from the US layout. nd it is definitely easier than switching to the konsole and type text.

In the System Settings -> Hardware -> Input Devices -> Keyboard -> Layouts folder, click on "Show Layout Indicator"
Below in the Layouts, assign a label to each of the layouts

Do not use the "Flag" or "label on flag" option, as the current monochrome systray doesn't show this correctly, especially not in Latte Dock.


Thank you for answer,
Yes, I do it, of course.

But I always should keep in mind it (current layout and what application I want to run).

For example, if I try to run a heavy application such as UnrealEngine with non-US layout, then all hotkeys will not work, even if you will switch layout to US (while UE is running).
So, I should close UE, switch layout manually, and run UE. It is steal a lot of time and and a bit annoying.

Same with a lot of games, etc.

I want to protect yourself from such trifles and automate that process for needed applications (and it is the part of "linux way", no? I should be able to automate all that I need).
User avatar
Mamarok
Manager
Posts
6071
Karma
16
OS

Re: Can't switch to another layout

Thu Feb 06, 2020 3:25 pm
Sounds like something you would need a script for, then. Not my expertise, sorry, but also not Plasma or KDE-specific.

To some extent you can edit the start menu command as well, of course, but if you want to switch back once the application ends this needs to be set in a script.


Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ...
rednull
Registered Member
Posts
28
Karma
0
OS

Re: Can't switch to another layout

Thu Feb 06, 2020 7:19 pm
Mamarok wrote:Sounds like something you would need a script for, then. Not my expertise, sorry, but also not Plasma or KDE-specific.

To some extent you can edit the start menu command as well, of course, but if you want to switch back once the application ends this needs to be set in a script.


I do not need to switch back at the end, it doesn't matter.
I just need to switch current layout to US by command line.

Well, as I understand right - it is not possible in KDE Plasma.
rednull
Registered Member
Posts
28
Karma
0
OS

Re: Can't switch to another layout

Fri Feb 07, 2020 5:50 am
Mamarok wrote:Sounds like something you would need a script for, then. Not my expertise, sorry, but also not Plasma or KDE-specific.

To some extent you can edit the start menu command as well, of course, but if you want to switch back once the application ends this needs to be set in a script.


Finally I produced a simple command to resolve the topic:
Code: Select all
CURRXKB=$(setxkbmap -query | grep layout | cut -d ' ' -f6) ; setxkbmap us ; sleep 1s ; setxkbmap $CURRXKB

Note: however, it will work only if "US" is a first layout in system settings.

---
UPD:
For second example it doen't metter, which layout is firs. However, finally it forcibly sets "US" as first:
Code: Select all
CURRXKB='us,'$(setxkbmap -query | grep layout | cut -d ' ' -f6 | sed "s/,us//g" | sed "s/us,//g") ; setxkbmap us ; sleep .1s ; setxkbmap $CURRXKB

---

Thank you for discussion :)
User avatar
Mamarok
Manager
Posts
6071
Karma
16
OS

Re: Can't switch to another layout

Fri Feb 07, 2020 11:16 am
rednull wrote:Well, as I understand right - it is not possible in KDE Plasma.


Just for completion' sake: Plasma is a GUI, so is most of the software made by the KDE Community, command line is common to all Linux and Unix-like systems, independent of the Graphical User Interface.


Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ...
rednull
Registered Member
Posts
28
Karma
0
OS
Mamarok wrote:
rednull wrote:Well, as I understand right - it is not possible in KDE Plasma.


Just for completion' sake: Plasma is a GUI, so is most of the software made by the KDE Community, command line is common to all Linux and Unix-like systems, independent of the Graphical User Interface.


In "global" sense you are right.
But actually in case of my question, sorry, but no.

As I told, I like KDE/ Plasma because it is very flexible and can be managed by dbus.

My previous solution (actually just a workaround) through setxkbmap is a bit ugly and I was looking more elegant way to switch.

Well, now I've found solution especially for KDE/Plasma through qdbus (thanks to qdbusviewer):
Code: Select all
/usr/bin/qdbus org.kde.keyboard /Layouts setLayout "us"
sergeimipt
Registered Member
Posts
2
Karma
0

Re: Can't switch to another layout

Mon Jan 03, 2022 5:02 pm
to toggle layouts i used

Code: Select all
/usr/bin/qdbus org.kde.keyboard /Layouts org.kde.KeyboardLayouts.switchToNextLayout
dzon
Registered Member
Posts
493
Karma
3

Re: Can't switch to another layout

Mon Jan 03, 2022 5:25 pm
Rednull has a point. Some commands aren't linux globally persé. I had a hard time figuring out a simple mv command to work in a script for example. Turns out it had to be kdemv5 specific.


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Google [Bot], Sogou [Bot]