I have a Macbook Air that runs Linux. I want to swap the alt and super keys in both sides of the keyboard with each other.How do I do this with cli tools?UpdateFollowing Drav Sloan's answer I used the following:keycode 64 = Alt_Lkeycode 133 = Super_Lremove Mod1 = Alt_Lremove Mod4 = Super_Ladd Mod1 = Super_Ladd Mod4 = Alt_Lkeycode 108 = Alt_Rkeycode 134 = Super_Rremove Mod1 = Alt_Rremove Mod4 = Super_Radd Mod1 = Super_Radd Mod4 = Alt_R
Swap alt and super
linux;keyboard layout;macintosh;xkb
One way to achieve that is via xmodmap. You can run xev to get key events. On running xev a box should appear and you can focus it and press the keys you want to swap. It should output details similar to for the Alt key:KeyPress event, serial 28, synthetic NO, window 0x8800001,  root 0x25, subw 0x0, time 2213877115, (126,91), root:(1639,475),  state 0x0, keycode 14 (keysym 0xffe9, Alt_L), same_screen YES,  XLookupString gives 0 bytes:   XmbLookupString gives 0 bytes:   XFilterEvent returns: FalseI'm on a PC, and dont have a Command Key, but have the equivalent Windows Key, andxev gives:KeyPress event, serial 28, synthetic NO, window 0x8000001,  root 0x25, subw 0x0, time 2213687746, (111,74), root:(1624,98),  state 0x0, keycode 93 (keysym 0xffeb, Super_L), same_screen YES,  XLookupString gives 0 bytes:   XmbLookupString gives 0 bytes:   XFilterEvent returns: FalseBecause xmodmap has no idea of state, and can easily break key mappings, I suggest you do a:xmodmap -pke > defaultsThen we create a xmodmap file:keycode 14 = Alt_Lkeycode 93 = Super_Lremove Mod1 = Alt_Lremove Mod4 = Super_Ladd Mod1 = Super_Ladd Mod4 = Alt_LNote how I'm using the keycodes that xev returned. Also here I'm only replacing the left super and alt keys (and leaving the right ones to their old behavior). Then we can simply run xmodmap, to set these keys:$ xmodmap -v modmap.file! modmap:! 1:  keycode 14 = Alt_L        keycode 0xe = Alt_L! 2:  keycode 93 = Super_L        keycode 0x5d = Super_L! 3:  remove Mod1 = Alt_L! Keysym Alt_L (0xffe9) corresponds to keycode(s) 0xe        remove mod1 =  0xe! 4:  remove Mod4 = Super_L! Keysym Super_L (0xffeb) corresponds to keycode(s) 0x5d        remove mod4 =  0x5d! 5:  add Mod1 = Super_L        add mod1 = Super_L! 6:  add Mod4 = Alt_L        add mod4 = Alt_L!! executing work queue!        keycode 0xe = Alt_L        keycode 0x5d = Super_L        remove mod1 =  0xe        remove mod4 =  0x5d        add mod1 = Super_L        add mod4 = Alt_LYou can run without the -v (verbose) switch for silent running, but I find it useful if you made mistakes in your modmap file. If things go messy then just reapply your defaults:xmodmap defaultsModmap is often ran at start up of X, so you can have these applied as defaults if you put your modmap commands in ~/.xmodmaprc.