2

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?

4
  • This rings a bell… Are you running into the same issue as unix.stackexchange.com/questions/4485/… ? Commented Oct 5, 2015 at 21:57
  • Thanks for the link. Yesterday I found out, too, that it was a problem caused by the fact that I didn't clear the groups before assigning new values like so: 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. Commented Oct 6, 2015 at 7:27
  • If you still need help, please edit your question to update it with what you're currently doing. If you're still getting error messages, add them. If you aren't getting error messages but the keys don't do what you want them do, describe what they do and what you want them to do instead. Commented Oct 6, 2015 at 10:00
  • Just updated my Question, @Gilles. Commented Oct 8, 2015 at 9:03

1 Answer 1

1

By now, I have a partial solution regarding the switching of ctrl and cmd on the left side.

It's stupid simple but alright for my purposes:

I use the Gnome Tweak Tool to change the behaviour of these keys. In my language there is an option called Input and under this option there is the fifth point from the top "Position of ctrl key" and I changed it to "Swap left super key and left ctrl key".

Must be something similar in other translations.

So far, I can now use the left cmd key for some standard shortcuts (cmd + c for copying, and so on). But unlike the keyboard on my Macbook at home, I can't toggle the window switching with cmd + tab. Therefore I need to use ctrl + tab or alt + tab. But that's ok, it's something you can get used to.

But unfortunately I still didn't find an option swapping both alt keys.

1
  • Also, I found the possibility in the default Gnome settings app under keyboard -> shortcuts, changing the behaviour of application/window switching from ctrl + tab to cmd + tab (remembering that the keys were swapped before so in fact it's ctrl + tab but mapped to cmd) Commented Oct 9, 2015 at 14:23

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.