You are not logged in.

#1 2013-02-11 14:58:36

Stack
Member
Registered: 2012-04-22
Posts: 13

Looking for a way to directly choose keyboard layout.

I'm looking for a way to organise separated keyboard keys combinations (or single keys - the best) for every keyboard layout. I want to be able to choose layout directly. One unique key (keys combination) for each layout.

One way may be smth. like setting a key to execute a command:
    setxkbmap -layout "us,ru"
and
    setxkbmap -layout "ru,us"
For keys setup in OpenBox may be used obkey, for example.

In general it works. But in such a case, when not latin/english layout is the first one, or even single one, in the command's layout list, applications will not react on Ctrl-S, Ctrl-Z and so on. It do not depend on current layout, it depend on the first entry in last sequence to be used in the layouts list.

I'm shure there are some other better ways to implement the idea. Please, give me advise: what a tool, or tool set to study and use?

Offline

#2 2013-02-11 16:02:09

the sad clown
Member
From: 192.168.0.X
Registered: 2011-03-20
Posts: 833

Re: Looking for a way to directly choose keyboard layout.

Have you tried this line in your xorg.conf:

        Option          "XkbOptions"    "grp:menu_toggle,grp_led:caps"

Modify it to meet your own needs re: unused keyboard shortcut.

Here is the wiki with more information on the subject:

XkbOptions: some extras. Here you can specify how do you want to switch the layouts, what led will be used for
    notification, a special way to enter the euro-sign, etc... For the possibilities, look at /usr/share/X11/xkb/rules/xorg
    and then for their descriptions in the appropriate file in /usr/share/X11/xkb/symbols/*

https://wiki.archlinux.org/index.php/Co … youts_in_X


I laugh, yet the joke is on me

Offline

#3 2013-02-11 16:16:03

the sad clown
Member
From: 192.168.0.X
Registered: 2011-03-20
Posts: 833

Re: Looking for a way to directly choose keyboard layout.

Oops, didn't really understand your question properly.  If you want seperate shortcut keys for each layout, I would use xbindkeys and bind this command to your desired keys (just make sure that the changed layout doesn't break your keybind):

setxkbmap -rules xorg -model pc104 -layout us -option

Just change the layout parameters (and any other changes you need) for as many layouts as you want.

Last edited by the sad clown (2013-02-11 16:17:24)


I laugh, yet the joke is on me

Offline

#4 2013-02-11 17:54:34

Stack
Member
Registered: 2012-04-22
Posts: 13

Re: Looking for a way to directly choose keyboard layout.

the sad clown wrote:

(just make sure that the changed layout doesn't break your keybind):

setxkbmap -rules xorg -model pc104 -layout us -option

Just change the layout parameters (and any other changes you need) for as many layouts as you want.

Unfortunately, if the single layout, or first in the list layout is not 'us', but my national, GUI applications will stop to react on Ctrl-S, Ctrl-Z and similar things.

Can it be fixed?

As I catch, for testing there is no difference between setxkbmap and xorg.conf. Also, there is no way to specify there layout specific switch combinations. In coma separated list of values for XKbOptions there is not binds to corresponding position in layouts list. All the combinations will do the same - cycle between layouts. http://www.xfree86.org/current/XKB-Config2.html#5

Layout itself and layout switching mechanics are too different objects (or classes) in terms of programming. I'm not shure I'll be on a right way, if I'll decide to dive deeply into syntax of '/usr/share/X11/xkb/rules/xorg' and '/usr/share/X11/xkb/symbols/*' (mentioned at https://wiki.archlinux.org/index.php/Co … _xorg.conf ) and hacking of ready to use layouts. If I'm searching for a way to switch them only. Am I right?

Last edited by Stack (2013-02-11 18:49:03)

Offline

#5 2013-02-16 03:40:03

the sad clown
Member
From: 192.168.0.X
Registered: 2011-03-20
Posts: 833

Re: Looking for a way to directly choose keyboard layout.

Stack wrote:
the sad clown wrote:

(just make sure that the changed layout doesn't break your keybind):

setxkbmap -rules xorg -model pc104 -layout us -option

Just change the layout parameters (and any other changes you need) for as many layouts as you want.

Unfortunately, if the single layout, or first in the list layout is not 'us', but my national, GUI applications will stop to react on Ctrl-S, Ctrl-Z and similar things.

Can it be fixed?

Is it that Ctrl-[S,Z] don't work or that they change locations because the keyboard layout has been modified?  The first is a problem, the second is to be expected if you are changing the keyboard layout.

Stack wrote:

As I catch, for testing there is no difference between setxkbmap and xorg.conf. Also, there is no way to specify there layout specific switch combinations. In coma separated list of values for XKbOptions there is not binds to corresponding position in layouts list. All the combinations will do the same - cycle between layouts. http://www.xfree86.org/current/XKB-Config2.html#5

Layout itself and layout switching mechanics are too different objects (or classes) in terms of programming. I'm not shure I'll be on a right way, if I'll decide to dive deeply into syntax of '/usr/share/X11/xkb/rules/xorg' and '/usr/share/X11/xkb/symbols/*' (mentioned at https://wiki.archlinux.org/index.php/Co … _xorg.conf ) and hacking of ready to use layouts. If I'm searching for a way to switch them only. Am I right?

My suggestion isn't that you use the XkbOptions switch since this won't work for what you are asking.  Instead, I'm recommending you use a little keyboard shortcut utility, xbindkeys and use that to issue the setxkbmap command I mentioned earlier.  All you have to do is bind the shortcut to keys that don't change across keyboard layout changes (if you have a number pad, an easy solution is to use a modifier + one of these keys as it won't change).  This isn't a toggle like the xorg.conf edit, but can switch to any layout you choose to bind in any order you choose to perform.


I laugh, yet the joke is on me

Offline

#6 2013-02-26 17:17:37

Stack
Member
Registered: 2012-04-22
Posts: 13

Re: Looking for a way to directly choose keyboard layout.

the sad clown wrote:

Is it that Ctrl-[S,Z] don't work or that they change locations because the keyboard layout has been modified?  The first is a problem, the second is to be expected if you are changing the keyboard layout.

It do not work, partially. For example, two variants of a commands for direct switching:

setxkbmap -option -layout "us,ru" -option 'grp:caps_toggle'
setxkbmap -option -layout "ru,us" -option 'grp:caps_toggle'

The only difference is 'us,ru' and 'ru,us'. When the first command is called, "physical" keys Ctrl+S combination working as expected at both layouts - Endlish one and national one. When the second command is called - Ctrl+S working only when 'us' is activated. The second is the only one variant of 'setxkbmap' command for direct switch to national layout. So, there is a way to bind a key and a command, but there is no a command, without loosing a lot of convenience.

There is KDE GUI application 'kkbswitch', it have the wanted options. But I do not want to install KDE parts, it's too hard for my "pocket" laptop.

Last edited by Stack (2013-02-26 17:18:40)

Offline

Board footer

Powered by FluxBB