Search code examples
ubuntukeyboardubuntu-16.04ctrlcapslock

setxkbmap setting lost when I switch keyboard layout in Ubuntu 16.04


I set my Caps Lock to be a Ctrl in Ubuntu 16.04 using: setxkbmap -option 'caps:ctrl_modifier' But when I change my keyboard from En to Cs, the Caps Lock becomes a Caps Lock again, not a Ctrl.

To fix it, I have to execute the above setxkbmap command again from a terminal.

How can I make the setting permanent, even if I switch keyboard layouts?


Solution

  • In order to make the options set by setxkbmap permanent, add them to /etc/default/keyboard as follows:

    --- a/etc/default/keyboard
    +++ b/etc/default/keyboard
    @@ -5,6 +5,6 @@
     XKBMODEL="pc105"
     XKBLAYOUT="us"
     XKBVARIANT=""
    -XKBOPTIONS=""
    +XKBOPTIONS="caps:ctrl_modifier"
    
     BACKSPACE="guess"
    

    Then the option caps:ctrl_modifier will be set even when the keyboard layout is switched from En to any other language.