Three useful commands:
1. Get the current keyboard layout, from this topic :
setxkbmap -print | grep xkb_symbols | awk -F"+" '{print $2}'
Returns layout(variant) where variant is optional
2. Know if the current keyboard layout is layout(variant):
setxkbmap -print | grep "layout(variant)"
Or without "(variant)".
Returns nothing is not.
3. Set the keyboard layout to a specified value:
setxkbmap layout variant
Where variant is optional.
(see man setxkbmap
for more informations)
What you can do:
1. Create a simple executable (chmod +x file
) script that changes the keyboard layout on the fly, depending on the current one. For instance, if we deal with the first point:
#!/bin/bash
if setxkbmap -print | grep "us"
then
setxkbmap ru
else
setxkbmap us
fi
2. With your keyboard shortcuts manager, assign the Shift-CapsLock
keys to this script.
Good luck!
Try that last one, i.e.:
% setxkbmap -I ~/.xkb prog -print | xkbcomp -I$HOME/.xkb - $DISPLAY
But put your layout in ~/.xkb/symbols/prog
(note the symbols subdirectory).
Best Answer
You'll have to define a custom option e.g.
win_caps_toggle
.Add the following definition to your
/usr/share/X11/xkb/symbols/group
:and the following description to your
usr/share/X11/xkb/rules/evdev.lst
:anywhere under the
grp
section (e.g. undergrp:caps_toggle
).You can then run
to set Win+CapsLock as the shortcut that changes the keyboard layout.
Note: this solution doesn't work with gnome 3. I think in order to make it work some stuff has to be disabled in gnome; I've tried disabling
gnome-settings-daemon
keyboard plugin andmutter
overview key but no go. Works fine with other DE's though.