Hot answers tagged

51

There are a lot of players between your keyboard and the process that finally handles the keyboard event. Among the major pieces of the landscape are the fact that the X system has its own keyboard-handling layer, and X associates different "keycodes" with keys than your Linux base system does. The showkey command is showing you the keycodes in Linux-base-...


37

From man xkeyboard-config: Key(s) to change layout ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │Option Description │ ├──────────────────────────────────────────────────────────────────────────────...


33

Take a look at localectl, especially following options: localectl list-x11-keymap-layouts - gives you layouts localectl list-x11-keymap-variants de gives you variants for this layout (or all variants if no layout specified) localectl list-x11-keymap-options | grep grp: - gives you all layout switching options


29

Maybe this is version dependent, but on my machine that uses setxkbmap 1.3.0 the following command works: setxkbmap -query | grep layout Note that depending on your need it may be useless to know only the layout : for instance the Dvorak variant of the US layout is quite different than the default QWERTY. The -query option of setxkbmap gives both the ...


28

I think I have a technique for disabling the toggling of the Capslock key but not completely disabling the key all together, or remapping it to another key on the keyboard. If you use the command: setxkbmap -option caps:none The keyboard will no longer toggle. I've confirmed this on my laptop running Fedora 14, the LED no longer lights up, and normal ...


26

xmodmap is obsolete; so indeed it should be done with the xkb tools. The swap you want seems not to be included by default wth X11 files; so you have to write it yourself. The page http://madduck.net/docs/extending-xkb/ helped me to understand and find a way to do it. Create a file ~/.xkb/keymap/mykbd where you put the output of setxkbmap, it will be your ...


24

xev should work Odd, my xev gives a KeyPress and KeyRelease event for alt (and for the Windows key, here called "super"): KeyPress event, serial 40, synthetic NO, window 0xae00001, root 0x2ca, subw 0x0, time 595467354, (98,77), root:(102,443), state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES, XLookupString gives 0 bytes: ...


24

If you're wanting to do this on an Apple keyboard, try this out: echo 1|sudo tee /sys/module/hid_apple/parameters/swap_opt_cmd To get this to work for a lower version of Linux you can try this out: http://blog.chaselambda.com/2014/10/09/apple-keyboard-on-linux-3.8.html


20

One way to achieve that is via xmodmap. You can run xev to get key events. On running xev a box should appear and you can focus it and press the keys you want to swap. It should output details similar to for the Alt key: KeyPress event, serial 28, synthetic NO, window 0x8800001, root 0x25, subw 0x0, time 2213877115, (126,91), root:(1639,475), state 0x0, ...


20

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 ...


20

Yes, Wayland uses XKB for keyboard layouts. But it's not quite the right question, because things work different than in X. Remember that Wayland is only a protocol (plus a wrapper library). At the protocol level, wayland has a wl_keyboard.keymap event. This event contains a file descriptor to the keymap and a format classifier. Right now, only one format ...


19

There are a bajillion answers on the internet, most of them confusing. The key is you need to map 'keycode 66' to your hyper key, remove the mapping of that key from other mod{1,2,4,5}'s (only if present), and then set mod3. Open ~/.Xmodmap and put the following: ! Unmap capslock clear Lock keycode 66 = Hyper_L ! Leave mod4 as windows key _only_ remove ...


17

You can accomplish this with xmodmap. Add the following to ~/.xmodmap: remove Lock = Caps_Lock keysym Caps_Lock = Control_L add Control = Control_L and run the command xmodmap ~/.xmodmap. You can put this command in whatever startup files are processed by your WM or DE. This will only work in X but it will work regardless of what graphical environment ...


16

Use the following command: setxkbmap -option caps:shiftlock


16

I found it. It was moved to the regional preferences section: Go to settings > regional preferences > keyboard layouts > settings and expand the caps lock section. UPDATE: In Linux Mint 17.1 you can get to it via; System Settings > Hardware > Keyboard > Keyboard Layouts > Options > Caps Lock key behavior


15

I "detect" three issues in your question: Why do xev and showkey report different keycodes for a key? Why does xev not show Alt being pressed properly? How to swap Alt and Win? Regarding the first question: these days, where the keyboard "driver" in X does not really drive the hardware, it could just pass-through the keycodes from the kernel to the X core, ...


13

Try looking in /usr/share/X11/xkb/symbols as described on the setxkbmap man page. The options can be found in various files, try doing a grep -rinH alts_toggle /usr/share/X11/xkb. /usr/share/X11/xkb/rules/xorg.xml looks like a good choice.


13

Yes THERE IS a command line tool that does what you want! I just discovered it 10min ago :) Look at here: https://github.com/nonpop/xkblayout-state xkblayout-state print "%s" does exactly what you want (it doesn't output an end of line, so add ; echo if you need). run the tool without parameters for the help.


13

Execute xfce4-settings-manager, in Session and Startup -> Application autostart, add an entry, which executes xmodmap ~/.xmodmap Or rename the file to ~/.Xmodmap


13

You could use xkb-switch (-n switches to next layout): xkb-switch -n or xkblayout-state (with set +1 to wrap around, in your case) : xkblayout-state set +1 or xte from xautomation to simulate Control_L+Shift_L key press/release: xte 'keydown Control_L' 'keydown Shift_L' 'keyup Shift_L' 'keyup Control_L'


13

If you only want to swap left alt and super key execute the command in your terminal: setxkbmap -option altwin:swap_alt_win To restore the default behavior just use: setxkbmap -option Note: This is temporary. If you want the effects permanently add it to your startup file.


13

Create a file containing your keycode changes, and save it as (for example) ~/.xkb/keycodes/local. (The keycodes directory is hard-coded; the base directory can be something else, and the filename too.) This will contain in your case xkb_keycodes { <PGUP> = 110; <PGDN> = 112; <DELE> = 115; <INS> = 117; <HOME> = 118; ...


11

The following commands should work: xmodmap -e 'keycode 0x42 = Caps_Lock' or setxkbmap -option The commands above work just fine to restore the default behaviour, which I hardly ever need, luckily. I normally remap the capslock to Control (luckily VI/VIM supports CTRL-C instead of ESC) with the following command: setxkbmap -option ctrl:nocaps -layout ...


11

Use this to get the code for the current layout: $(xset -q|grep LED| awk '{ print $10 }') This might needs to be converted to a form you want, like: case "$(xset -q|grep LED| awk '{ print $10 }')" in "00000002") KBD="English" ;; "00001002") KBD="Thai" ;; *) KBD="unknown" ;; esac


11

As root, run: showkey -s ...to see what the scancode is for your mystery key. I got something like this: # showkey -s kb mode was RAW [ if you are trying this under X, it might not work since the X server is also reading /dev/console ] press any key (program terminates 10s after last keypress)... 0xc6 0x46 0xc6 0xc6 0x46 0xc6 0x46 Not sure why it ...


11

I was trying to solve this for myself and I just figured it out. The main problem is that you aren't getting the event for the keypress. Looking at the log you posted the reason is apparent. FocusOut event, serial 36, synthetic NO, window 0x4a00001, mode NotifyGrab, detail NotifyAncestor FocusIn event, serial 36, synthetic NO, window 0x4a00001, ...


11

This seems to accomplish what you're looking for. partial modifier_keys xkb_symbols "compose" { key <CAPS> { type[Group1] = "TWO_LEVEL", symbols[Group1] = [ Multi_key, Caps_Lock ], actions[Group1] = [ NoAction(), LockMods(modifiers=Lock) ] }; }; The following resources are invaluable when dealing with XKB (I've linked ...


10

EDIT: Still trying... Testing shows that the keymap will ONLY take a single key in each position. BUT, if you use a rare/never used keysym in the keymap definition, then a global Xmodmap to make THAT keysym output the various unicode characters you need, this'll work. In the keymap: key <AB04> { [ v, V, XF86LaunchA, XF86LaunchB ] }; In a global ...


10

Yes, Gnome overrides the xkb X settings. You can set xkb layout/options in Gnome either using the CLI tools gsettings/dconf or via the GUI tool dconf-editor. So, using gsettings, open a terminal and run: gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('xkb', 'us+altgr-intl'), ('xkb', 'us+colemak')]" and gsettings set org.gnome....


10

You'll have to define a new option. First, make a new symbol file e.g. /usr/share/X11/xkb/symbols/bksp with the following content: partial alphanumeric_keys xkb_symbols "bksp_escape" { key <BKSP> { [ Escape ] }; }; Then create the new option like this: bksp:bksp_escape = +bksp(bksp_escape) (where bksp is the name of the symbol file and ...


Only top voted, non community-wiki answers of a minimum length are eligible