Non cyclic switching between keyboard layouts
Hi all.
I have three keyboard layouts: en, ru and ua. Now I switch between layouts by pressing Ctrl+Shift (en->ru->ua->en->ru...). Here is part of my xorg.conf Code:
Option "XkbRules" "xorg" CapsLock - switch to en CapsLock+Shift - switch to ru CapsLock+Ctrl - switch to ua I've read an xkb manuals and some articles about it but can't understand how I can setup xkb for non cyclic switching. Can anyone help me? |
I'm not sure if it can be done with any regular keyboard mapping tool. The standard X switching mechanism seems to be a simple rotate.
It appears, however, that you can instead use one of the input method frameworks, uim or scim, to work with languages that have different keboard mappings, and these can be configured with separate shortcuts for each layout. I've never personally tried either of them for languages like that though. See here for more on Linux language support. http://www.jw-stumpel.nl/stestu.html |
Here is one way to do it, which involves hacking the files in /usr/share/X11/xkb (alternatively you could set up your own keymap files). This is to select four keyboard layouts, but it will work for three.
First, add in a CapsLock selector type to the default xkb_types section in xkb/types/extra (this will be used to allow the CapsLock to select up to 4 different actions) Code:
type "FOUR_LEVEL_CAPS" { Code:
interpret ISO_First_Group_Lock { Code:
partial modifier_keys Code:
grp:shift_ctrl_caps_switch = +group(shift_ctrl_caps_switch) The four layouts are selected using 'capslock', 'shift-capslock', 'ctrl-capslock', and 'shift-ctrl-capslock' (as defined in the switch map). |
Many thanks, neonsignal! This is what I need.
But I have a small problem with this. When I switch first layout by pressing CapsLock it switches correctly, then I press CapsLock+Shift to switch to the second layout and it switches correctly too. But when I press CapsLock again I get third layout instead of first. When I switch from third layot to first all works fine. This is because I have only three layouts I'm right? |
Quote:
I'm assuming that you didn't make any changes to the above. It would be worth looking at the Xorg log to see if there were any errors (these may also appear on the ctrl-alt-F1 terminal window). |
... If you work only in GUI, then why can't you just bind "setxkbmap en" "setxkbmap ru" and "setxkbmap ua" to any key combo you want?
|
Quote:
Switching from first to second layout works. Switching from first to third and from third to first works too. When I switch from second layout to first I get third layout and need to press CapsLock again to perform switching. Quote:
Also I've look in Xorg.log and as I can see there are no errors related to the keyboard Xorg log: http://www.4shared.com/file/22332535.../Xorg0log.html xkb files with edits: http://www.4shared.com/file/22332503...ed/xkbtar.html |
Quote:
This explains why I didn't see it earlier, because I was running setxkbmap to try out different combinations. I don't know why setxkbmap would make a difference. My guess is that the setup order must be slightly different when X windows first starts, and something else is adding a definition to the capslock. ==EDIT== Looking at the keymap (using xkbcomp) after X windows starts, CAPS is set to: Code:
key <CAPS> { [CODE] Code:
key <CAPS> { |
Many thanks neonsignal!
Now all works and my understanding was much better |
All times are GMT -5. The time now is 12:21 AM. |