How to swap Command and Control keys with xkb step by step?Permanent xmodmap in Ubuntu 13.04How do I switch the Command key and Control key on a MacBook Pro?How to swap ctrl and alt keys in ubuntu 16.04?How to cleanly swap alt and ctrl keys in xubuntu?Xmodmap keymap on Bluetooth keyboardAfter swapping Ctrl and caps in xmodmap, how can I make Ctrl work properly for multi-modifier combinations?How can I remap “special” keys in xkb?Remap Command/Apple key to work as the control keyHow to achieve Mac-like use of CTRL and CMD keys on Apple Keyboard?How can I swap Left Meta for an arbitrary key (preferably using xkb)?How to cleanly swap alt and ctrl keys in xubuntu?Request for a guide on setting up Apple Aluminium keyboard on Ubuntu 16.04Reassigning modifier keys with xkb

Is there a key for the map icons in game?

How do I compile something for Linux if I don't have enough space for installing GCC?

Confused about Autoregressive AR(1) process

How much of a discount should I seek when prepaying a whole year's rent?

Is "Are you interviewing other candidates?" a good or terrible response when asked if you are interviewing with other companies?

Why did Sparta turn on its ally Elis during the First Macedonian War?

Key takeaways in German in a presentation

Have spacecraft photographed each other beyond Earth orbit?

What is a Aged Rope Phrase™?

How do successful undergraduate and PhD students differ?

Why do we have to make the sign of the Cross physically?

Ballot anonymity at UK polling stations

Selecting point with maximum value for each polygon

Sleep for 1000 years

What is the reason for difference between integer division and float to int conversion in python?

What specifically can swap do that RAM can't

What would be the difference between dual-wielding a rapier and dagger vs. two shortswords?

Will the same Javascript fetched by HTTP and HTTPS be cached separately by the browser?

What does "你舒服吗" mean in a relationship context?

Sudden cheap travel?

Fourier transform is an isomorphism...but we don’t get when each frequency appears?

Can I ignore an open source license if I checkout a version that was released prior to the code having any license?

What is a logic gate?

Thoughts on if it's possible to succeed in math @ PhD level w/o natural ability in quant reasoning?



How to swap Command and Control keys with xkb step by step?


Permanent xmodmap in Ubuntu 13.04How do I switch the Command key and Control key on a MacBook Pro?How to swap ctrl and alt keys in ubuntu 16.04?How to cleanly swap alt and ctrl keys in xubuntu?Xmodmap keymap on Bluetooth keyboardAfter swapping Ctrl and caps in xmodmap, how can I make Ctrl work properly for multi-modifier combinations?How can I remap “special” keys in xkb?Remap Command/Apple key to work as the control keyHow to achieve Mac-like use of CTRL and CMD keys on Apple Keyboard?How can I swap Left Meta for an arbitrary key (preferably using xkb)?How to cleanly swap alt and ctrl keys in xubuntu?Request for a guide on setting up Apple Aluminium keyboard on Ubuntu 16.04Reassigning modifier keys with xkb






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









9


















I want to use my Apple long aluminium keyboard with swapped Command Cmd and Control 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.










share|improve this question






















  • 1





    This solution did not work for me. It is most likely outdated (actually I'm pretty sure, just can't find the reference now). I did try it before posting. That's why I specified the Ubuntu version.

    – Aleksandar Savkov
    Apr 14 '15 at 15:49






  • 1





    @WaldirLeoncio I hope this makes it clear why the question is NOT a duplicate: askubuntu.com/questions/325272/…

    – Aleksandar Savkov
    Apr 15 '15 at 10:24


















9


















I want to use my Apple long aluminium keyboard with swapped Command Cmd and Control 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.










share|improve this question






















  • 1





    This solution did not work for me. It is most likely outdated (actually I'm pretty sure, just can't find the reference now). I did try it before posting. That's why I specified the Ubuntu version.

    – Aleksandar Savkov
    Apr 14 '15 at 15:49






  • 1





    @WaldirLeoncio I hope this makes it clear why the question is NOT a duplicate: askubuntu.com/questions/325272/…

    – Aleksandar Savkov
    Apr 15 '15 at 10:24














9













9









9


5






I want to use my Apple long aluminium keyboard with swapped Command Cmd and Control 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.










share|improve this question
















I want to use my Apple long aluminium keyboard with swapped Command Cmd and Control 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.







keyboard-layout xkb apple-keyboard






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:23









Community

1




1










asked Jul 23 '14 at 17:10









Aleksandar SavkovAleksandar Savkov

2602 silver badges11 bronze badges




2602 silver badges11 bronze badges










  • 1





    This solution did not work for me. It is most likely outdated (actually I'm pretty sure, just can't find the reference now). I did try it before posting. That's why I specified the Ubuntu version.

    – Aleksandar Savkov
    Apr 14 '15 at 15:49






  • 1





    @WaldirLeoncio I hope this makes it clear why the question is NOT a duplicate: askubuntu.com/questions/325272/…

    – Aleksandar Savkov
    Apr 15 '15 at 10:24













  • 1





    This solution did not work for me. It is most likely outdated (actually I'm pretty sure, just can't find the reference now). I did try it before posting. That's why I specified the Ubuntu version.

    – Aleksandar Savkov
    Apr 14 '15 at 15:49






  • 1





    @WaldirLeoncio I hope this makes it clear why the question is NOT a duplicate: askubuntu.com/questions/325272/…

    – Aleksandar Savkov
    Apr 15 '15 at 10:24








1




1





This solution did not work for me. It is most likely outdated (actually I'm pretty sure, just can't find the reference now). I did try it before posting. That's why I specified the Ubuntu version.

– Aleksandar Savkov
Apr 14 '15 at 15:49





This solution did not work for me. It is most likely outdated (actually I'm pretty sure, just can't find the reference now). I did try it before posting. That's why I specified the Ubuntu version.

– Aleksandar Savkov
Apr 14 '15 at 15:49




1




1





@WaldirLeoncio I hope this makes it clear why the question is NOT a duplicate: askubuntu.com/questions/325272/…

– Aleksandar Savkov
Apr 15 '15 at 10:24






@WaldirLeoncio I hope this makes it clear why the question is NOT a duplicate: askubuntu.com/questions/325272/…

– Aleksandar Savkov
Apr 15 '15 at 10:24











3 Answers
3






active

oldest

votes


















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.






share|improve this answer






















  • 2





    Should be !option = symbols section, not options = symbols (spent time searching for "options =" to find the section).

    – Ben Davis
    Apr 27 '17 at 19:46












  • See also here: reddit.com/r/Ubuntu/comments/8lnr8q/remapping_keys

    – Aleksandar Savkov
    Oct 27 '18 at 11:09











  • Like most things with xkb and xmodmap, doesn't work, probably broke my system in other way, I'm sick of this crap and I really wish linux would get its crap together with the most basic freaking thing about key mapping and binding.

    – Seph
    Sep 20 at 10:22











  • Do mind this was written in 2014 and doesn’t apply to modern distributions.

    – Aleksandar Savkov
    Sep 22 at 8:40


















2



















In 16.04, here's the way I finally got this to work.
Xmodmap doesn't work universally in all apps, gnome tweak tool lacked the function, dconf editing a custom altwin2 key swap (like the main answer here) failed, so I was tearing my hair out until I combined several answers into this complete, simple, and elegant solution:



gksudo gedit /usr/share/X11/xkb/symbols/pc


change it to:



default partial alphanumeric_keys modifier_keys
xkb_symbols "pc105"

key <ESC> [ Escape ] ;

// The extra key on many European keyboards:
key <LSGT> [ less, greater, bar, brokenbar ] ;

// The following keys are common to all layouts.
key <BKSL> [ backslash, bar ] ;
key <SPCE> [ space ] ;

include "srvr_ctrl(fkey2vt)"
include "pc(editing)"
include "keypad(x11)"

key <BKSP> [ BackSpace, BackSpace ] ;

key <TAB> [ Tab, ISO_Left_Tab ] ;
key <RTRN> [ Return ] ;

key <CAPS> [ Caps_Lock ] ;
key <NMLK> [ Num_Lock ] ;

key <LFSH> [ Shift_L ] ;
key <LCTL> [ Alt_L ] ;
key <LWIN> [ Super_L ] ;

key <RTSH> [ Shift_R ] ;
key <RCTL> [ Alt_R ] ;
key <RWIN> [ Super_R ] ;
key <MENU> [ Menu ] ;

// Beginning of modifier mappings.
modifier_map Shift Shift_L, Shift_R ;
modifier_map Lock Caps_Lock ;
modifier_map Control Control_L, Control_R ;
modifier_map Mod2 Num_Lock ;
modifier_map Mod4 Super_L, Super_R ;

// Fake keys for virtual<->real modifiers mapping:
key <LVL3> [ ISO_Level3_Shift ] ;
key <MDSW> [ Mode_switch ] ;
modifier_map Mod5 <LVL3>, <MDSW> ;

key <ALT> [ NoSymbol, Control_L, Control_R ] ;
//include "altwin(meta_alt)"
key <LALT> [ Control_L ] ;
key <RALT> [ Control_R ] ;
modifier_map Mod1 Alt_L, Alt_R, Meta_L, Meta_R ;

key <META> [ NoSymbol, Meta_L, Meta_R ] ;
modifier_map Mod1 <META> ;

key <SUPR> [ NoSymbol, Super_L ] ;
modifier_map Mod4 <SUPR> ;

key <HYPR> [ NoSymbol, Hyper_L ] ;
modifier_map Mod4 <HYPR> ;
// End of modifier mappings.

key <OUTP> [ XF86Display ] ;
key <KITG> [ XF86KbdLightOnOff ] ;
key <KIDN> [ XF86KbdBrightnessDown ] ;
key <KIUP> [ XF86KbdBrightnessUp ] ;
;

hidden partial alphanumeric_keys
xkb_symbols "editing"
key <PRSC>
type= "PC_ALT_LEVEL2",
symbols[Group1]= [ Print, Sys_Req ]
;
key <SCLK> [ Scroll_Lock ] ;
key <PAUS>
type= "PC_CONTROL_LEVEL2",
symbols[Group1]= [ Pause, Break ]
;
key <INS> [ Insert ] ;
key <HOME> [ Home ] ;
key <PGUP> [ Prior ] ;
key <DELE> [ Delete ] ;
key <END> [ End ] ;
key <PGDN> [ Next ] ;

key <UP> [ Up ] ;
key <LEFT> [ Left ] ;
key <DOWN> [ Down ] ;
key <RGHT> [ Right ] ;
;


Save.



rm -rf /var/lib/xkb/*


(I don't know if this is required, but I did it.)



Reboot.






share|improve this answer



























  • Thanks for that. I will test it when I migrate to 16.04 in the near future.

    – Aleksandar Savkov
    Oct 12 '16 at 8:47











  • Just used this on my 16.10 upgrade. Worked very nicely.

    – Tom Mercer
    Oct 21 '16 at 5:49


















0



















You may find Kinto to be useful. It's a project I recently created, after a few years of tackling this problem a few different ways and I just now feel like it's solid enough to share.



The Kinto installer simply uses python to do the initial install, after that it's just a systemd service, bash, xprop, setxkbmap and xkbcomp. As far as I am concerned it is the fastest and most native solution to this problem that you are going to find.



https://github.com/rbreaves/kinto



https://medium.com/@benreaves/kinto-a-mac-inspired-keyboard-mapping-for-linux-58f731817c0



Here's a Gist as well, if you just want to see what is at the heart of it all, it will not alternate your keymap when needed though. The Gist also does not include custom xkb keymap files that setup macOS style cursors/word-wise manipulations that use Cmd and the arrow keys.



https://gist.github.com/rbreaves/f4cf8a991eaeea893999964f5e83eebb



gist content



# permanent apple keyboard keyswap
echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf
update-initramfs -u -k all

# Temporary & instant apple keyboard keyswap
echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd

# Windows and Mac keyboards - GUI (Physical Alt is Ctrl, Physical Super is Alt, Physical Ctrl is Super)
setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win

# Windows and Mac keyboards - Terminal Apps (Physical Alt is Super, Physical Super is Alt, Physical Ctrl is Ctrl)
setxkbmap -option;setxkbmap -option altwin:swap_alt_win

#
# If you want a systemd service and bash script to help toggle between
# GUI and Terminal applications then look at project Kinto.
# https://github.com/rbreaves/kinto
#
# Note: The above may not work for Chromebooks running Linux, please look
# at project Kinto for that.
#
# If anyone would like to contribute to the project then please do!
#





share|improve this answer


























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f501659%2fhow-to-swap-command-and-control-keys-with-xkb-step-by-step%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown


























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    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.






    share|improve this answer






















    • 2





      Should be !option = symbols section, not options = symbols (spent time searching for "options =" to find the section).

      – Ben Davis
      Apr 27 '17 at 19:46












    • See also here: reddit.com/r/Ubuntu/comments/8lnr8q/remapping_keys

      – Aleksandar Savkov
      Oct 27 '18 at 11:09











    • Like most things with xkb and xmodmap, doesn't work, probably broke my system in other way, I'm sick of this crap and I really wish linux would get its crap together with the most basic freaking thing about key mapping and binding.

      – Seph
      Sep 20 at 10:22











    • Do mind this was written in 2014 and doesn’t apply to modern distributions.

      – Aleksandar Savkov
      Sep 22 at 8:40















    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.






    share|improve this answer






















    • 2





      Should be !option = symbols section, not options = symbols (spent time searching for "options =" to find the section).

      – Ben Davis
      Apr 27 '17 at 19:46












    • See also here: reddit.com/r/Ubuntu/comments/8lnr8q/remapping_keys

      – Aleksandar Savkov
      Oct 27 '18 at 11:09











    • Like most things with xkb and xmodmap, doesn't work, probably broke my system in other way, I'm sick of this crap and I really wish linux would get its crap together with the most basic freaking thing about key mapping and binding.

      – Seph
      Sep 20 at 10:22











    • Do mind this was written in 2014 and doesn’t apply to modern distributions.

      – Aleksandar Savkov
      Sep 22 at 8:40













    7















    7











    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.






    share|improve this answer
















    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.







    share|improve this answer















    share|improve this answer




    share|improve this answer








    edited Sep 30 at 14:28









    Gints

    32 bronze badges




    32 bronze badges










    answered Jul 23 '14 at 17:10









    Aleksandar SavkovAleksandar Savkov

    2602 silver badges11 bronze badges




    2602 silver badges11 bronze badges










    • 2





      Should be !option = symbols section, not options = symbols (spent time searching for "options =" to find the section).

      – Ben Davis
      Apr 27 '17 at 19:46












    • See also here: reddit.com/r/Ubuntu/comments/8lnr8q/remapping_keys

      – Aleksandar Savkov
      Oct 27 '18 at 11:09











    • Like most things with xkb and xmodmap, doesn't work, probably broke my system in other way, I'm sick of this crap and I really wish linux would get its crap together with the most basic freaking thing about key mapping and binding.

      – Seph
      Sep 20 at 10:22











    • Do mind this was written in 2014 and doesn’t apply to modern distributions.

      – Aleksandar Savkov
      Sep 22 at 8:40












    • 2





      Should be !option = symbols section, not options = symbols (spent time searching for "options =" to find the section).

      – Ben Davis
      Apr 27 '17 at 19:46












    • See also here: reddit.com/r/Ubuntu/comments/8lnr8q/remapping_keys

      – Aleksandar Savkov
      Oct 27 '18 at 11:09











    • Like most things with xkb and xmodmap, doesn't work, probably broke my system in other way, I'm sick of this crap and I really wish linux would get its crap together with the most basic freaking thing about key mapping and binding.

      – Seph
      Sep 20 at 10:22











    • Do mind this was written in 2014 and doesn’t apply to modern distributions.

      – Aleksandar Savkov
      Sep 22 at 8:40







    2




    2





    Should be !option = symbols section, not options = symbols (spent time searching for "options =" to find the section).

    – Ben Davis
    Apr 27 '17 at 19:46






    Should be !option = symbols section, not options = symbols (spent time searching for "options =" to find the section).

    – Ben Davis
    Apr 27 '17 at 19:46














    See also here: reddit.com/r/Ubuntu/comments/8lnr8q/remapping_keys

    – Aleksandar Savkov
    Oct 27 '18 at 11:09





    See also here: reddit.com/r/Ubuntu/comments/8lnr8q/remapping_keys

    – Aleksandar Savkov
    Oct 27 '18 at 11:09













    Like most things with xkb and xmodmap, doesn't work, probably broke my system in other way, I'm sick of this crap and I really wish linux would get its crap together with the most basic freaking thing about key mapping and binding.

    – Seph
    Sep 20 at 10:22





    Like most things with xkb and xmodmap, doesn't work, probably broke my system in other way, I'm sick of this crap and I really wish linux would get its crap together with the most basic freaking thing about key mapping and binding.

    – Seph
    Sep 20 at 10:22













    Do mind this was written in 2014 and doesn’t apply to modern distributions.

    – Aleksandar Savkov
    Sep 22 at 8:40





    Do mind this was written in 2014 and doesn’t apply to modern distributions.

    – Aleksandar Savkov
    Sep 22 at 8:40













    2



















    In 16.04, here's the way I finally got this to work.
    Xmodmap doesn't work universally in all apps, gnome tweak tool lacked the function, dconf editing a custom altwin2 key swap (like the main answer here) failed, so I was tearing my hair out until I combined several answers into this complete, simple, and elegant solution:



    gksudo gedit /usr/share/X11/xkb/symbols/pc


    change it to:



    default partial alphanumeric_keys modifier_keys
    xkb_symbols "pc105"

    key <ESC> [ Escape ] ;

    // The extra key on many European keyboards:
    key <LSGT> [ less, greater, bar, brokenbar ] ;

    // The following keys are common to all layouts.
    key <BKSL> [ backslash, bar ] ;
    key <SPCE> [ space ] ;

    include "srvr_ctrl(fkey2vt)"
    include "pc(editing)"
    include "keypad(x11)"

    key <BKSP> [ BackSpace, BackSpace ] ;

    key <TAB> [ Tab, ISO_Left_Tab ] ;
    key <RTRN> [ Return ] ;

    key <CAPS> [ Caps_Lock ] ;
    key <NMLK> [ Num_Lock ] ;

    key <LFSH> [ Shift_L ] ;
    key <LCTL> [ Alt_L ] ;
    key <LWIN> [ Super_L ] ;

    key <RTSH> [ Shift_R ] ;
    key <RCTL> [ Alt_R ] ;
    key <RWIN> [ Super_R ] ;
    key <MENU> [ Menu ] ;

    // Beginning of modifier mappings.
    modifier_map Shift Shift_L, Shift_R ;
    modifier_map Lock Caps_Lock ;
    modifier_map Control Control_L, Control_R ;
    modifier_map Mod2 Num_Lock ;
    modifier_map Mod4 Super_L, Super_R ;

    // Fake keys for virtual<->real modifiers mapping:
    key <LVL3> [ ISO_Level3_Shift ] ;
    key <MDSW> [ Mode_switch ] ;
    modifier_map Mod5 <LVL3>, <MDSW> ;

    key <ALT> [ NoSymbol, Control_L, Control_R ] ;
    //include "altwin(meta_alt)"
    key <LALT> [ Control_L ] ;
    key <RALT> [ Control_R ] ;
    modifier_map Mod1 Alt_L, Alt_R, Meta_L, Meta_R ;

    key <META> [ NoSymbol, Meta_L, Meta_R ] ;
    modifier_map Mod1 <META> ;

    key <SUPR> [ NoSymbol, Super_L ] ;
    modifier_map Mod4 <SUPR> ;

    key <HYPR> [ NoSymbol, Hyper_L ] ;
    modifier_map Mod4 <HYPR> ;
    // End of modifier mappings.

    key <OUTP> [ XF86Display ] ;
    key <KITG> [ XF86KbdLightOnOff ] ;
    key <KIDN> [ XF86KbdBrightnessDown ] ;
    key <KIUP> [ XF86KbdBrightnessUp ] ;
    ;

    hidden partial alphanumeric_keys
    xkb_symbols "editing"
    key <PRSC>
    type= "PC_ALT_LEVEL2",
    symbols[Group1]= [ Print, Sys_Req ]
    ;
    key <SCLK> [ Scroll_Lock ] ;
    key <PAUS>
    type= "PC_CONTROL_LEVEL2",
    symbols[Group1]= [ Pause, Break ]
    ;
    key <INS> [ Insert ] ;
    key <HOME> [ Home ] ;
    key <PGUP> [ Prior ] ;
    key <DELE> [ Delete ] ;
    key <END> [ End ] ;
    key <PGDN> [ Next ] ;

    key <UP> [ Up ] ;
    key <LEFT> [ Left ] ;
    key <DOWN> [ Down ] ;
    key <RGHT> [ Right ] ;
    ;


    Save.



    rm -rf /var/lib/xkb/*


    (I don't know if this is required, but I did it.)



    Reboot.






    share|improve this answer



























    • Thanks for that. I will test it when I migrate to 16.04 in the near future.

      – Aleksandar Savkov
      Oct 12 '16 at 8:47











    • Just used this on my 16.10 upgrade. Worked very nicely.

      – Tom Mercer
      Oct 21 '16 at 5:49















    2



















    In 16.04, here's the way I finally got this to work.
    Xmodmap doesn't work universally in all apps, gnome tweak tool lacked the function, dconf editing a custom altwin2 key swap (like the main answer here) failed, so I was tearing my hair out until I combined several answers into this complete, simple, and elegant solution:



    gksudo gedit /usr/share/X11/xkb/symbols/pc


    change it to:



    default partial alphanumeric_keys modifier_keys
    xkb_symbols "pc105"

    key <ESC> [ Escape ] ;

    // The extra key on many European keyboards:
    key <LSGT> [ less, greater, bar, brokenbar ] ;

    // The following keys are common to all layouts.
    key <BKSL> [ backslash, bar ] ;
    key <SPCE> [ space ] ;

    include "srvr_ctrl(fkey2vt)"
    include "pc(editing)"
    include "keypad(x11)"

    key <BKSP> [ BackSpace, BackSpace ] ;

    key <TAB> [ Tab, ISO_Left_Tab ] ;
    key <RTRN> [ Return ] ;

    key <CAPS> [ Caps_Lock ] ;
    key <NMLK> [ Num_Lock ] ;

    key <LFSH> [ Shift_L ] ;
    key <LCTL> [ Alt_L ] ;
    key <LWIN> [ Super_L ] ;

    key <RTSH> [ Shift_R ] ;
    key <RCTL> [ Alt_R ] ;
    key <RWIN> [ Super_R ] ;
    key <MENU> [ Menu ] ;

    // Beginning of modifier mappings.
    modifier_map Shift Shift_L, Shift_R ;
    modifier_map Lock Caps_Lock ;
    modifier_map Control Control_L, Control_R ;
    modifier_map Mod2 Num_Lock ;
    modifier_map Mod4 Super_L, Super_R ;

    // Fake keys for virtual<->real modifiers mapping:
    key <LVL3> [ ISO_Level3_Shift ] ;
    key <MDSW> [ Mode_switch ] ;
    modifier_map Mod5 <LVL3>, <MDSW> ;

    key <ALT> [ NoSymbol, Control_L, Control_R ] ;
    //include "altwin(meta_alt)"
    key <LALT> [ Control_L ] ;
    key <RALT> [ Control_R ] ;
    modifier_map Mod1 Alt_L, Alt_R, Meta_L, Meta_R ;

    key <META> [ NoSymbol, Meta_L, Meta_R ] ;
    modifier_map Mod1 <META> ;

    key <SUPR> [ NoSymbol, Super_L ] ;
    modifier_map Mod4 <SUPR> ;

    key <HYPR> [ NoSymbol, Hyper_L ] ;
    modifier_map Mod4 <HYPR> ;
    // End of modifier mappings.

    key <OUTP> [ XF86Display ] ;
    key <KITG> [ XF86KbdLightOnOff ] ;
    key <KIDN> [ XF86KbdBrightnessDown ] ;
    key <KIUP> [ XF86KbdBrightnessUp ] ;
    ;

    hidden partial alphanumeric_keys
    xkb_symbols "editing"
    key <PRSC>
    type= "PC_ALT_LEVEL2",
    symbols[Group1]= [ Print, Sys_Req ]
    ;
    key <SCLK> [ Scroll_Lock ] ;
    key <PAUS>
    type= "PC_CONTROL_LEVEL2",
    symbols[Group1]= [ Pause, Break ]
    ;
    key <INS> [ Insert ] ;
    key <HOME> [ Home ] ;
    key <PGUP> [ Prior ] ;
    key <DELE> [ Delete ] ;
    key <END> [ End ] ;
    key <PGDN> [ Next ] ;

    key <UP> [ Up ] ;
    key <LEFT> [ Left ] ;
    key <DOWN> [ Down ] ;
    key <RGHT> [ Right ] ;
    ;


    Save.



    rm -rf /var/lib/xkb/*


    (I don't know if this is required, but I did it.)



    Reboot.






    share|improve this answer



























    • Thanks for that. I will test it when I migrate to 16.04 in the near future.

      – Aleksandar Savkov
      Oct 12 '16 at 8:47











    • Just used this on my 16.10 upgrade. Worked very nicely.

      – Tom Mercer
      Oct 21 '16 at 5:49













    2















    2











    2









    In 16.04, here's the way I finally got this to work.
    Xmodmap doesn't work universally in all apps, gnome tweak tool lacked the function, dconf editing a custom altwin2 key swap (like the main answer here) failed, so I was tearing my hair out until I combined several answers into this complete, simple, and elegant solution:



    gksudo gedit /usr/share/X11/xkb/symbols/pc


    change it to:



    default partial alphanumeric_keys modifier_keys
    xkb_symbols "pc105"

    key <ESC> [ Escape ] ;

    // The extra key on many European keyboards:
    key <LSGT> [ less, greater, bar, brokenbar ] ;

    // The following keys are common to all layouts.
    key <BKSL> [ backslash, bar ] ;
    key <SPCE> [ space ] ;

    include "srvr_ctrl(fkey2vt)"
    include "pc(editing)"
    include "keypad(x11)"

    key <BKSP> [ BackSpace, BackSpace ] ;

    key <TAB> [ Tab, ISO_Left_Tab ] ;
    key <RTRN> [ Return ] ;

    key <CAPS> [ Caps_Lock ] ;
    key <NMLK> [ Num_Lock ] ;

    key <LFSH> [ Shift_L ] ;
    key <LCTL> [ Alt_L ] ;
    key <LWIN> [ Super_L ] ;

    key <RTSH> [ Shift_R ] ;
    key <RCTL> [ Alt_R ] ;
    key <RWIN> [ Super_R ] ;
    key <MENU> [ Menu ] ;

    // Beginning of modifier mappings.
    modifier_map Shift Shift_L, Shift_R ;
    modifier_map Lock Caps_Lock ;
    modifier_map Control Control_L, Control_R ;
    modifier_map Mod2 Num_Lock ;
    modifier_map Mod4 Super_L, Super_R ;

    // Fake keys for virtual<->real modifiers mapping:
    key <LVL3> [ ISO_Level3_Shift ] ;
    key <MDSW> [ Mode_switch ] ;
    modifier_map Mod5 <LVL3>, <MDSW> ;

    key <ALT> [ NoSymbol, Control_L, Control_R ] ;
    //include "altwin(meta_alt)"
    key <LALT> [ Control_L ] ;
    key <RALT> [ Control_R ] ;
    modifier_map Mod1 Alt_L, Alt_R, Meta_L, Meta_R ;

    key <META> [ NoSymbol, Meta_L, Meta_R ] ;
    modifier_map Mod1 <META> ;

    key <SUPR> [ NoSymbol, Super_L ] ;
    modifier_map Mod4 <SUPR> ;

    key <HYPR> [ NoSymbol, Hyper_L ] ;
    modifier_map Mod4 <HYPR> ;
    // End of modifier mappings.

    key <OUTP> [ XF86Display ] ;
    key <KITG> [ XF86KbdLightOnOff ] ;
    key <KIDN> [ XF86KbdBrightnessDown ] ;
    key <KIUP> [ XF86KbdBrightnessUp ] ;
    ;

    hidden partial alphanumeric_keys
    xkb_symbols "editing"
    key <PRSC>
    type= "PC_ALT_LEVEL2",
    symbols[Group1]= [ Print, Sys_Req ]
    ;
    key <SCLK> [ Scroll_Lock ] ;
    key <PAUS>
    type= "PC_CONTROL_LEVEL2",
    symbols[Group1]= [ Pause, Break ]
    ;
    key <INS> [ Insert ] ;
    key <HOME> [ Home ] ;
    key <PGUP> [ Prior ] ;
    key <DELE> [ Delete ] ;
    key <END> [ End ] ;
    key <PGDN> [ Next ] ;

    key <UP> [ Up ] ;
    key <LEFT> [ Left ] ;
    key <DOWN> [ Down ] ;
    key <RGHT> [ Right ] ;
    ;


    Save.



    rm -rf /var/lib/xkb/*


    (I don't know if this is required, but I did it.)



    Reboot.






    share|improve this answer
















    In 16.04, here's the way I finally got this to work.
    Xmodmap doesn't work universally in all apps, gnome tweak tool lacked the function, dconf editing a custom altwin2 key swap (like the main answer here) failed, so I was tearing my hair out until I combined several answers into this complete, simple, and elegant solution:



    gksudo gedit /usr/share/X11/xkb/symbols/pc


    change it to:



    default partial alphanumeric_keys modifier_keys
    xkb_symbols "pc105"

    key <ESC> [ Escape ] ;

    // The extra key on many European keyboards:
    key <LSGT> [ less, greater, bar, brokenbar ] ;

    // The following keys are common to all layouts.
    key <BKSL> [ backslash, bar ] ;
    key <SPCE> [ space ] ;

    include "srvr_ctrl(fkey2vt)"
    include "pc(editing)"
    include "keypad(x11)"

    key <BKSP> [ BackSpace, BackSpace ] ;

    key <TAB> [ Tab, ISO_Left_Tab ] ;
    key <RTRN> [ Return ] ;

    key <CAPS> [ Caps_Lock ] ;
    key <NMLK> [ Num_Lock ] ;

    key <LFSH> [ Shift_L ] ;
    key <LCTL> [ Alt_L ] ;
    key <LWIN> [ Super_L ] ;

    key <RTSH> [ Shift_R ] ;
    key <RCTL> [ Alt_R ] ;
    key <RWIN> [ Super_R ] ;
    key <MENU> [ Menu ] ;

    // Beginning of modifier mappings.
    modifier_map Shift Shift_L, Shift_R ;
    modifier_map Lock Caps_Lock ;
    modifier_map Control Control_L, Control_R ;
    modifier_map Mod2 Num_Lock ;
    modifier_map Mod4 Super_L, Super_R ;

    // Fake keys for virtual<->real modifiers mapping:
    key <LVL3> [ ISO_Level3_Shift ] ;
    key <MDSW> [ Mode_switch ] ;
    modifier_map Mod5 <LVL3>, <MDSW> ;

    key <ALT> [ NoSymbol, Control_L, Control_R ] ;
    //include "altwin(meta_alt)"
    key <LALT> [ Control_L ] ;
    key <RALT> [ Control_R ] ;
    modifier_map Mod1 Alt_L, Alt_R, Meta_L, Meta_R ;

    key <META> [ NoSymbol, Meta_L, Meta_R ] ;
    modifier_map Mod1 <META> ;

    key <SUPR> [ NoSymbol, Super_L ] ;
    modifier_map Mod4 <SUPR> ;

    key <HYPR> [ NoSymbol, Hyper_L ] ;
    modifier_map Mod4 <HYPR> ;
    // End of modifier mappings.

    key <OUTP> [ XF86Display ] ;
    key <KITG> [ XF86KbdLightOnOff ] ;
    key <KIDN> [ XF86KbdBrightnessDown ] ;
    key <KIUP> [ XF86KbdBrightnessUp ] ;
    ;

    hidden partial alphanumeric_keys
    xkb_symbols "editing"
    key <PRSC>
    type= "PC_ALT_LEVEL2",
    symbols[Group1]= [ Print, Sys_Req ]
    ;
    key <SCLK> [ Scroll_Lock ] ;
    key <PAUS>
    type= "PC_CONTROL_LEVEL2",
    symbols[Group1]= [ Pause, Break ]
    ;
    key <INS> [ Insert ] ;
    key <HOME> [ Home ] ;
    key <PGUP> [ Prior ] ;
    key <DELE> [ Delete ] ;
    key <END> [ End ] ;
    key <PGDN> [ Next ] ;

    key <UP> [ Up ] ;
    key <LEFT> [ Left ] ;
    key <DOWN> [ Down ] ;
    key <RGHT> [ Right ] ;
    ;


    Save.



    rm -rf /var/lib/xkb/*


    (I don't know if this is required, but I did it.)



    Reboot.







    share|improve this answer















    share|improve this answer




    share|improve this answer








    edited Oct 11 '16 at 22:41

























    answered Oct 11 '16 at 21:59









    Tom MercerTom Mercer

    1,1772 gold badges9 silver badges27 bronze badges




    1,1772 gold badges9 silver badges27 bronze badges















    • Thanks for that. I will test it when I migrate to 16.04 in the near future.

      – Aleksandar Savkov
      Oct 12 '16 at 8:47











    • Just used this on my 16.10 upgrade. Worked very nicely.

      – Tom Mercer
      Oct 21 '16 at 5:49

















    • Thanks for that. I will test it when I migrate to 16.04 in the near future.

      – Aleksandar Savkov
      Oct 12 '16 at 8:47











    • Just used this on my 16.10 upgrade. Worked very nicely.

      – Tom Mercer
      Oct 21 '16 at 5:49
















    Thanks for that. I will test it when I migrate to 16.04 in the near future.

    – Aleksandar Savkov
    Oct 12 '16 at 8:47





    Thanks for that. I will test it when I migrate to 16.04 in the near future.

    – Aleksandar Savkov
    Oct 12 '16 at 8:47













    Just used this on my 16.10 upgrade. Worked very nicely.

    – Tom Mercer
    Oct 21 '16 at 5:49





    Just used this on my 16.10 upgrade. Worked very nicely.

    – Tom Mercer
    Oct 21 '16 at 5:49











    0



















    You may find Kinto to be useful. It's a project I recently created, after a few years of tackling this problem a few different ways and I just now feel like it's solid enough to share.



    The Kinto installer simply uses python to do the initial install, after that it's just a systemd service, bash, xprop, setxkbmap and xkbcomp. As far as I am concerned it is the fastest and most native solution to this problem that you are going to find.



    https://github.com/rbreaves/kinto



    https://medium.com/@benreaves/kinto-a-mac-inspired-keyboard-mapping-for-linux-58f731817c0



    Here's a Gist as well, if you just want to see what is at the heart of it all, it will not alternate your keymap when needed though. The Gist also does not include custom xkb keymap files that setup macOS style cursors/word-wise manipulations that use Cmd and the arrow keys.



    https://gist.github.com/rbreaves/f4cf8a991eaeea893999964f5e83eebb



    gist content



    # permanent apple keyboard keyswap
    echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf
    update-initramfs -u -k all

    # Temporary & instant apple keyboard keyswap
    echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd

    # Windows and Mac keyboards - GUI (Physical Alt is Ctrl, Physical Super is Alt, Physical Ctrl is Super)
    setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win

    # Windows and Mac keyboards - Terminal Apps (Physical Alt is Super, Physical Super is Alt, Physical Ctrl is Ctrl)
    setxkbmap -option;setxkbmap -option altwin:swap_alt_win

    #
    # If you want a systemd service and bash script to help toggle between
    # GUI and Terminal applications then look at project Kinto.
    # https://github.com/rbreaves/kinto
    #
    # Note: The above may not work for Chromebooks running Linux, please look
    # at project Kinto for that.
    #
    # If anyone would like to contribute to the project then please do!
    #





    share|improve this answer





























      0



















      You may find Kinto to be useful. It's a project I recently created, after a few years of tackling this problem a few different ways and I just now feel like it's solid enough to share.



      The Kinto installer simply uses python to do the initial install, after that it's just a systemd service, bash, xprop, setxkbmap and xkbcomp. As far as I am concerned it is the fastest and most native solution to this problem that you are going to find.



      https://github.com/rbreaves/kinto



      https://medium.com/@benreaves/kinto-a-mac-inspired-keyboard-mapping-for-linux-58f731817c0



      Here's a Gist as well, if you just want to see what is at the heart of it all, it will not alternate your keymap when needed though. The Gist also does not include custom xkb keymap files that setup macOS style cursors/word-wise manipulations that use Cmd and the arrow keys.



      https://gist.github.com/rbreaves/f4cf8a991eaeea893999964f5e83eebb



      gist content



      # permanent apple keyboard keyswap
      echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf
      update-initramfs -u -k all

      # Temporary & instant apple keyboard keyswap
      echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd

      # Windows and Mac keyboards - GUI (Physical Alt is Ctrl, Physical Super is Alt, Physical Ctrl is Super)
      setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win

      # Windows and Mac keyboards - Terminal Apps (Physical Alt is Super, Physical Super is Alt, Physical Ctrl is Ctrl)
      setxkbmap -option;setxkbmap -option altwin:swap_alt_win

      #
      # If you want a systemd service and bash script to help toggle between
      # GUI and Terminal applications then look at project Kinto.
      # https://github.com/rbreaves/kinto
      #
      # Note: The above may not work for Chromebooks running Linux, please look
      # at project Kinto for that.
      #
      # If anyone would like to contribute to the project then please do!
      #





      share|improve this answer



























        0















        0











        0









        You may find Kinto to be useful. It's a project I recently created, after a few years of tackling this problem a few different ways and I just now feel like it's solid enough to share.



        The Kinto installer simply uses python to do the initial install, after that it's just a systemd service, bash, xprop, setxkbmap and xkbcomp. As far as I am concerned it is the fastest and most native solution to this problem that you are going to find.



        https://github.com/rbreaves/kinto



        https://medium.com/@benreaves/kinto-a-mac-inspired-keyboard-mapping-for-linux-58f731817c0



        Here's a Gist as well, if you just want to see what is at the heart of it all, it will not alternate your keymap when needed though. The Gist also does not include custom xkb keymap files that setup macOS style cursors/word-wise manipulations that use Cmd and the arrow keys.



        https://gist.github.com/rbreaves/f4cf8a991eaeea893999964f5e83eebb



        gist content



        # permanent apple keyboard keyswap
        echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf
        update-initramfs -u -k all

        # Temporary & instant apple keyboard keyswap
        echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd

        # Windows and Mac keyboards - GUI (Physical Alt is Ctrl, Physical Super is Alt, Physical Ctrl is Super)
        setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win

        # Windows and Mac keyboards - Terminal Apps (Physical Alt is Super, Physical Super is Alt, Physical Ctrl is Ctrl)
        setxkbmap -option;setxkbmap -option altwin:swap_alt_win

        #
        # If you want a systemd service and bash script to help toggle between
        # GUI and Terminal applications then look at project Kinto.
        # https://github.com/rbreaves/kinto
        #
        # Note: The above may not work for Chromebooks running Linux, please look
        # at project Kinto for that.
        #
        # If anyone would like to contribute to the project then please do!
        #





        share|improve this answer














        You may find Kinto to be useful. It's a project I recently created, after a few years of tackling this problem a few different ways and I just now feel like it's solid enough to share.



        The Kinto installer simply uses python to do the initial install, after that it's just a systemd service, bash, xprop, setxkbmap and xkbcomp. As far as I am concerned it is the fastest and most native solution to this problem that you are going to find.



        https://github.com/rbreaves/kinto



        https://medium.com/@benreaves/kinto-a-mac-inspired-keyboard-mapping-for-linux-58f731817c0



        Here's a Gist as well, if you just want to see what is at the heart of it all, it will not alternate your keymap when needed though. The Gist also does not include custom xkb keymap files that setup macOS style cursors/word-wise manipulations that use Cmd and the arrow keys.



        https://gist.github.com/rbreaves/f4cf8a991eaeea893999964f5e83eebb



        gist content



        # permanent apple keyboard keyswap
        echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf
        update-initramfs -u -k all

        # Temporary & instant apple keyboard keyswap
        echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd

        # Windows and Mac keyboards - GUI (Physical Alt is Ctrl, Physical Super is Alt, Physical Ctrl is Super)
        setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win

        # Windows and Mac keyboards - Terminal Apps (Physical Alt is Super, Physical Super is Alt, Physical Ctrl is Ctrl)
        setxkbmap -option;setxkbmap -option altwin:swap_alt_win

        #
        # If you want a systemd service and bash script to help toggle between
        # GUI and Terminal applications then look at project Kinto.
        # https://github.com/rbreaves/kinto
        #
        # Note: The above may not work for Chromebooks running Linux, please look
        # at project Kinto for that.
        #
        # If anyone would like to contribute to the project then please do!
        #






        share|improve this answer













        share|improve this answer




        share|improve this answer










        answered Aug 7 at 6:45









        R Ben RR Ben R

        213 bronze badges




        213 bronze badges































            draft saved

            draft discarded















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f501659%2fhow-to-swap-command-and-control-keys-with-xkb-step-by-step%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown









            Popular posts from this blog

            Distance measures on a map of a game The 2019 Stack Overflow Developer Survey Results Are Inmin distance in a graphShortest distance path on contour plotHow to plot a tilted map?Finding points outside of a diskDelaunay link distanceAnnulus from GeoDisks: drawing a ring on a mapNegative Correlation DistanceFind distance along a path (GPS coordinates)Finding position at given distance in a GeoPathMathematics behind distance estimation using camera

            How to get a smooth, uniform ParametricPlot of a 2D Region?How to plot a complicated Region?How to exclude a region from ParametricPlotHow discretize a region placing vertices on a specific non-uniform gridHow to transform a Plot or a ParametricPlot into a RegionHow can I get a smooth plot of a bounded region?Smooth ParametricPlot3D with RegionFunction?Smooth border of a region ParametricPlotSmooth region boundarySmooth region plot from list of pointsGet minimum y of a certain x in a region

            Genealogie vun de Merowenger Vum Merowech bis zum Chilperich I. | Navigatiounsmenü