Saturday, May 4, 2024
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 12519  / 2 Years ago, tue, august 9, 2022, 12:14:15

I want to use my Apple long aluminium keyboard with swapped Command and Ctrl keys. How is this done step by step on Trusty Tahr (14.04) using xkb?


Note: This solution doesn't work for me as xkb replaced xmodmap in 13.04 or even earlier.


More From » keyboard-layout

 Answers
7

This answer is mostly based on the answer given here. The reason I ask and answer this question again is the final step, which was not fully described. For further reading about xkb look here, here, and here.




  1. Create a file in /usr/share/X11/xkb/symbols (could also be in /etc/X11/xkb/symbols) called altwin2 and containing the following mapping:



    // Control is SWAPPED with Win-keys 
    partial modifier_keys
    xkb_symbols "cmd_n_ctrl" {
    key <LWIN> { [ Control_L ] };
    key <RWIN> { [ Control_R ] };
    key <LCTL> { [ Super_L ] };
    modifier_map Control { <LWIN>, <RWIN> };
    modifier_map Mod4 { <LCTL> };
    };

  2. Insert the following line under the option = symbols section in /usr/share/X11/xkb/rules/evdev (disregard the warning on the first line):



    altwin2:cmd_n_ctrl               =       +altwin2(cmd_n_ctrl)

  3. Add the new option to /usr/share/X11/xkb/rules/evdev.lst under the section option:



    altwin2:cmd_n_ctrl    Win swapped with Ctrl

  4. If you don't know where your keyboard configuration file is, you can edit it using dconf-editor, adding "altwin2:cmd_n_ctrl" in xkb-options under org::gnome::desktop::input-sources as shown here. If you know where your configuration file is, you should include the new option in the XkbOptions field as shown below:



    Section "InputClass"
    Identifier "keyboard-layout"
    Driver "evdev"
    MatchIsKeyboard "yes"
    Option "XkbLayout" "us, ru, ca, fr"
    Option "XkbOptions" "altwin2:cmd_n_ctrl"
    EndSection

  5. Either reboot or restart lightdm to update the changes:



    sudo restart lightdm



NOTE: if any changes are made directly in the layout files, i.e. not using options, the cached files in /var/lib/xkb/ need to be deleted as indicated here.


[#24009] Tuesday, August 9, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rmiend

Total Points: 292
Total Questions: 101
Total Answers: 111

Location: Azerbaijan
Member since Tue, Aug 9, 2022
2 Years ago
rmiend questions
Tue, Jan 18, 22, 23:52, 2 Years ago
Sat, Sep 17, 22, 15:44, 2 Years ago
;