Skip to content

Instantly share code, notes, and snippets.

@wfxr
Last active July 22, 2016 16:03
Show Gist options
  • Save wfxr/f3e4587830dba7cb5740 to your computer and use it in GitHub Desktop.
Save wfxr/f3e4587830dba7cb5740 to your computer and use it in GitHub Desktop.

Solution 1

Add .Xmodmap to home directory:

! output taken from:
! xmodmap -pke | egrep '(Control|Caps)'
! Use to set keycodes correctly below. List reordered to match
! keys from left to right.

!keycode  37 = Control_L NoSymbol Control_L
!keycode  66 = Caps_Lock NoSymbol Caps_Lock
!keycode 105 = Control_R NoSymbol Control_R

! First clear all modifiers, caps lock & control
clear Lock
clear Control

keycode 37 = Caps_Lock
keycode 66 = Control_L

add Control = Control_L
add Lock = Caps_Lock

To disable Alt for search in ubuntu, Go to System Settings --> Keyboard --> Shortcuts --> Launchers and delete Key to Show the HUD

Problems:

https://fcitx-im.org/wiki/FAQ#xmodmap_settings_being_overwritten xmodmap settings being overwritten Fcitx now control keyboard layout and when switch layout, xmodmap setting will be overwritten. So fcitx-xkb provides an option to specify the xmodmap script and let fcitx loads it for you whenever keyboard layout changes. Or disable fcitx-xkb addon is also a solution for you, or if your requirement is simply, for example, switching Caps Lock and Esc, which is provided by xkb option, you can just set it with your desktop keyboard configuration tool (Gnome and KDE all support such configuration).

For more detailed explanation, xmodmap is a very low level tool, that doesn't aware keyboard layout. For X11, keyboard layout is built on a set of profile, when such profile is loaded, anything you changed with xmodmap will be overwritten, this isn't specific to fcitx, but all tool that support keyboard layout configuration. Xkb option is a set of profile that can do some pre-defined change over keyboard layout, including many thing that people usually do with xmodmap, for example, defining where dead key is, switching Caps Lock and Esc, and so on. Unless you have special requirements, xkb layout and xkb option is recommended.

Since 4.2.7, Fcitx will try to load ~/.Xmodmap if it exists.

Solution 2

Execute commond:

  setxkbmap -option "ctrl:swapcaps"

To enabled auto start, add it to /etc/rc.local:

sudo sed -i 's|^exit 0.*$|# Swap Ctrl and CapsLock\nsetxkbmap -option "ctrl:swapcaps"\n\nexit 0|' /etc/rc.local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment