I often switch between English and Greek layouts and this has been a minor annoyance for a while. Your question pushed me to solve it, so thanks!
I found a program that can do this: xbindkeys
. The proceedure I followed (adapted from here) was:
Install xbindkeys
. On my Debian this is done with
sudo apt-get install xbindkeys
You should also be able to install easily enough with the equivalent yum install
or pacman -S
or whatever commands.
Create the default settings file:
xbindkeys --defaults > ~/.xbindkeysrc
Get the right keycodes for your keys. Run xbindkeys -k
and press your desired shortcut. With my keyboard at least (though this should be standard), xbindkeys -k
reports that CtrlT is
m:0x14 + c:28
Control+Mod2 + t
Create the relevant shortcut, add these lines to ~/.xbindkeysrc
:
"xterm"
m:0x14 + c:28
Run xbindkeys
. The shortcut now works even in the Greek layout. To make this permanent, add this to your ~/.Xsession
:
xbindkeys
General background: Keys get assigned three different sets of "codes", first the scancode (arbitrary hardware dependent number the represents the key on the keyboard), then the keycode (more abstract number that represents a particular key, e.g. shift or 1 / !), and finally the keysym (key symbol, the actual symbol like á
produced by a key or combination of keys).
I recently learned that each /dev/input/event*
device carries its own scancode-to-keycode mapping. These mappings can be read and altered by iotcls (EVIOCGKEYCODE_V2
, EVIOCSKEYCODE_V2
), but funnily enough, there don't seem to be general tools available to access these mappings (I quickly wrote a simple C program dump it, as I was curious).
Both the Linux kernel and X then map keycodes to keysyms. For the kernel, there's just one global mapping, the kbd
handler (or at least one global mapping for very virtual console, I'm not sure if different virtual consoles can have different mappings). X maintains a mapping for each device.
So if you want differences between keyboards on the virtual console, the only choice left is to use the scancode-to-keycode mapping. For Dvorak vs. Qwerty this might actually work as long as you just remap letter keys, and don't want to remap symbols in shifted and non-shifted state differently.
More recent versions of udev use a hardware database (/etc/udev/hwdb.d
) to initialize special scancode-to-keycode mappings, and you can add your own custom versions.
The alternative is to live with either Dvorak or Qwerty on the virtual console, but setup X to use different keycode-to-keysym mappings for each, as described in the answer you linked that didn't help you (probably because you don't want this variant). The advantage of this method is that you can also map symbols, dead keys, compositions etc. differently.
Best Answer
If you haven't set the keyboard layout system-wide, you can specify it in
Xfce 4 Settings Manager
.For Setting Keyboard Layout, do the following steps:
Open Xfce 4 Settings Manager :
Menu ⟹ Settings ⟹ Settings Manager
Click on the Keyboard icon.
Switch to the Layout tab.
Uncheck Use system defaults
Click the Add button and choose the appropriate keymap from the list.
Select the active layout.
For editing shortcuts, do the following:
Xfce4 parameters ⟹ window manager settings ⟹ Keyboard tab
In addition, if you want to switch between different layouts, you can use and download its plugins.
N.B. If above solutions didn't help, I recommend you read this article, I haven't tried that myself, but I think it might help. On this step if you are faced with any problem, the solution provided here from askubuntu might help.