I'm trying to change some specific keys on my USB Apple keyboard running Fedora 22.
Just spent three days searching for an answer and trying different solutions, I ended up using xmodmap and still can't get it all to work.
My exact problems are:
- Swapping the Alt Left key with the Alt Right
- Swapping the Ctrl Left key with the cmd Left key
So far, this is what I tried at last:
I made a copy of my xmodmap file:
xmodmap -pke ~/.xmodmap
Then I figured out the keycodes of the keys I'm trying to switch using xev which gave me for Alt Left and Alt Right:
KeyPress event, serial 36, synthetic NO, window 0x3400001,
root 0xd7, subw 0x0, time 7033878, (38,-14), root:(38,23),
state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x3400001,
root 0xd7, subw 0x0, time 7035742, (38,-14), root:(38,23),
state 0x10, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
XKeysymToKeycode returns keycode: 92
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
So, the Alt Left key is using keycode 64, and the Alt Right key, which is named ISO_Level3_Shift, is using the keycode 108.
Regarding to other sources across the web, I created a new xmodmap file with this content:
keycode 64 = Alt_L
keycode 108 = ISO_Level3_Shift
remove Mod1 = Alt_L
remove Mod4 = ISO_Level3_Shift
add Mod1 = ISO_Level3_Shift
add Mod4 = Alt_L
Then I tried to run this new config:
xmodmap -v .mymodmap
And got this errors:
! .mymodmap:
! 1: keycode 64 = Alt_L
keycode 0x40 = Alt_L
! 2: keycode 108 = ISO_Level3_Shift
keycode 0x6c = ISO_Level3_Shift
! 3: remove Mod1 = Alt_L
! Keysym Alt_L (0xffe9) corresponds to keycode(s) 0x40 0xcc
remove mod1 = 0x40 0xcc
! 4: remove Mod4 = ISO_Level3_Shift
! Keysym ISO_Level3_Shift (0xfe03) corresponds to keycode(s) 0x5c 0x6c 0x9a
remove mod4 = 0x5c 0x6c 0x9a
! 5: add Mod1 = ISO_Level3_Shift
add mod1 = ISO_Level3_Shift
! 6: add Mod4 = Alt_L
add mod4 = Alt_L
!
! executing work queue
!
keycode 0x40 = Alt_L
keycode 0x6c = ISO_Level3_Shift
remove mod1 = 0x40 0xcc
remove mod4 = 0x5c 0x6c 0x9a
add mod1 = ISO_Level3_Shift
add mod4 = Alt_L
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 15
Current serial number in output stream: 15
This leaves me confused although I'm searching for solutions.
Does anyone have a clue or a source with informations how to change specific keys on a new Apple keyboard?
Edit:
So far, after trying out several configs, I ended up with my nearest approach looking like this:
clear mod1
clear mod5
keycode 64 = ISO_Level3_Shift Mode_switch ISO_Level3_Shift Mode_switch
keycode 92 = Alt_L Meta_L Alt_L Meta_L
keycode 108 = Alt_L Meta_L Alt_L Meta_L
add mod1 = ISO_Level3_Shift Mode_switch
add mod5 = Alt_L Meta_L
Keycode 92 and 108 seem to be the same key as I can see in the xev outputs.
This is my xmodmap output before my changes:
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
And this is my xmodmap output after my changes:
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x69)
mod1 ISO_Level3_Shift (0x40), Mode_switch (0xcb)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 Alt_L (0x5c), Alt_L (0x6c), Alt_L (0xcc), Meta_L (0xcd)
After applying these changes, my right Alt key seems to work like my left Alt key (e.g. toggling Menus in some applications) but the left Alt key isn't doing anything.
Maybe, to concretise my intentions:
I need to switch both Alt keys for my programming purposes, as I want my Apple keyboard here in my office to work like my keyboard at home (where I use a Macbook).
I am heavily used to write special symbols like tilde ~ and pipes | and so on with my left Alt key (triggering the left Alt key with my left thumb).
Also I need to switch left cmd with left ctrl as these are also switched on my Macbook at home.
Surely, I could get used to these switched keys here in work, but this is annoying me every day, as I'm pressing the wrong key combinations when I'm in my flow not thinking about the correct keys.
So, does anybody have some help here for me?
xmodmap -e "clear mod1"
Unfortunately, the new assignments still don't work. I assigned the same values from the Alt Right to Alt Left but the key is without function.