keyboard remapping lost after keyboard layout change
|June 30, 2014||Posted by forumadmin under TechQns||
I see similar questions have already been asked before on this site, by I found no satisfactory answer so far. So here’s my exact situation in detail.
I recently installed and customized Ubuntu 14.04 on a MacBook Air (with the Unity desktop) and it works very well for the most part, but I still have one remaining issue with the keyboard layout.
I often need to switch between French Canadian and American English keyboard layouts (English being the default). I wanted to both remap the Mac modifier keys to a more PC-like layout and correct a bad out-of-the-box mapping of the backquote/tilda key in the upper-left corner of the keyboard (which gives me the < > symbols instead). After looking for solutions, I ended up putting the following code in a file called xmodmappings located in ~/.config/autostart :
! clean most of the modifiers clear control clear mod4 clear mod1 ! ----------------- ! left side ! ---------------- ! keycode 64 is the left alt key keycode 64 = Super_L ! key code 133 is the left command key keycode 133 = Alt_L Meta_L ! ------------------ ! right side ! ------------------- ! key code 134 is the right command key keycode 134 = Alt_R Meta_R ! keycode 108 is the right alt key keycode 108 = Control_R add mod4 = Super_L add mod1 = Alt_L Meta_L add mod1 = Alt_R Meta_R add control = Control_L add control = Control_R ! Remapping the upper-left key (keycode 94) keycode 94 = grave asciitilde
I also put a file called xmodmappings.desktop in the same directory with the following content and made sure it was visible and activated in the startup applications window:
[Desktop Entry] Type=Application Exec=xmodmap /home/sebastien/.config/autostart/xmodmappings Hidden=false NoDisplay=false X-GNOME-Autostart-enabled=true Name=xmodmap Comment=Change keyboard configuration
After doing all that, everything worked fine on startup with the default English layout. Now here’s my problem. When I switch to the French layout using the Alt+Space keyboard shortcut, I lose the remapping of modifier keys. When I switch back to English, the problem persists and I also get back the incorrect mapping of the backquote/tilda key. In other words, the effect of calling xmod is cancelled when I switch layout, so I have to call “xmodmap xmodmappings” manually afterwards.
Is there a way I can automatically call a xmod remapping script every time I switch keyboard layout? Preferably, I should be able to remap the upper-left key in a different way depending on whether I switch from French to English or the other way around.
|Asked By – Bastro3000||Read Answers|