Here's another question about remapping keys in modern Linux distributions.


I've been a Mac user for the past six years and a Linux user for ~20 years. This has caused two problems:

  • Coding on a swedish keyboard on a Mac is horrible, so I've been forced to use a US layout while coding
  • Constantly switching between keyboard layouts on Linux and Mac

On the Mac I've made some changes to the US layout to get access to the swedish characters (å, ä, ö). To get those characters on a swedish keyboard there are normally three keys on the right of the keyboard. I've remapped those with Ukelele so that normally they work as on a US layout, but with "alt" (or "alt+shift") pressed I get the swedish characters. After some time getting used to this it works very well.

Secondly, it's quite common for Linux users to remap the ctrl-win-alt keys so that the win-key acts like a second ctrl-key. This makes most shortcuts work the same on Mac and Linux. There is a setting for this in GNOME (or GNOME Tweaks): "Ctrl is mapped to Win and the usual Ctrl keys".

But the order is still not the same as on a Mac-keyboard: the mac has "control option command", but a PC keyboard has "ctrl win alt". There is another option in GNOME Tweaks: "Alt is swapped with Win". Unfortunately GNOME Tweaks only allows one of these options.

So here's the complete remapping I want (based on a US layout):

  • Alt + "[" => å
  • Alt + Shift + "['"=> Å
  • Alt + "'" => ä
  • Alt + Shift + "'" => Ä
  • Alt + ";" => ö
  • Alt + Shift + ";" => Ö
  • Left Ctrl => Left Ctrl
  • Left Win => Left Alt
  • Left Alt => Left Ctrl

Unfortunately there seems to be so many options how to achieve this, and all of them are quite hard to get right, so I would appreciate any help on this!

(On the Mac I was able to do this using Ukelele, a graphical tool to build a keyboard layout which is then installed so that I can switch to it just as easily as you can switch between a US or Swedish layout. Very nice.)


I have the Ctrl/Alt/Win part solved. I created a new filed (named "jomag" in my case) and placed it in "/usr/share/X11/xkb/symbols/":

partial modifier_keys              
xkb_symbols "jomag" {     
        key <LALT> { [ Control_L, Control_L ] };     
        key <LWIN> { [ Alt_L, Alt_L ] };             
        modifier_map Control { <LALT>, <LWIN> };     

I also added a line to /usr/share/X11/xkb/rules/evdev:

! option     =    symbols
jomag:jomag  =    +jomag(jomag)    <--- this one

I'm not sure it was necessary though.

I found that the best way to load it is using setxkbmap:

setxkbmap -option jomag:jomag

To reload, run with empty option:

setxkbmap -option
setxkbmap -option jomag:jomag
  • The problem with mapping two modifier keys (Left Ctrl and Left Alt) to one modifier key (Left Ctrl) is that now you can only use this single modifier key to do mappings (though maybe it can be made to work with some XKB magic, but that's a complicated topic). So would you be ok with Ctrl + "[" => å in addition to Alt + "[" etc.? (BTW, I've been doing pretty much the same things as you, except for German äöü, and I recently started using a Mac, made a custom layout instead of using Ukele, and now I fight with the Mac constantly switching the keyboard layout back to "pure" EN...) – dirkt Mar 2 '18 at 10:59
  • not sure if i understand it correctly, but my ideal solution would be to have three keys at the bottom left: ctrl, alt, ctrl. Pressing Alt+[ should give "å", but not Ctrl+[ – Jonatan Mar 2 '18 at 12:13
  • That will be difficult. :-( – dirkt Mar 2 '18 at 12:21
  • In that case, it would be ok with Ctrl-[ giving "å" as well. Or would it be easier to use AltGr + ] ? – Jonatan Mar 2 '18 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.