0

I am using the Mac Canadian Multilingual keyboard with Ubuntu 16, shown below. The Canadian Multilingual text entry option works almost fine, but I have the following problems.

  1. The left alt and right alt are swapped. I have to press on the right alt key in order to write the brackets { and } (that makes coding and writing in Latex very difficult).

  2. The keys for ù and / are also swapped.

How can I fix this? I tried everything suggested in the related posts on this site (and elsewhere), to no avail.

I tried using an English configuration for my keyboard, only switching to French when necessary, but this makes me waste too much time.

Note: This problem is very serious for French-Canadian Ubuntu users. I must keep my MacBook air next to my Ubuntu desktop to write emails and to write in Latex.

Attempted fixes:

  • Using xev, I found that the left alt is keycode 64, registered as Alt_L, right alt is keycode 108, registered as ISO_Level3_Shift. The command xmodmap -e "keycode 64 = ISO_Level3_Shift" makes the left alt key unresponsive whitout fixing the problem.

  • In the file '/usr/share/X11/xkb/symbols/ca', I swapped the content (what is in the brackets) between the two following lines:

    key <TLDE>  { [     slash,  backslash,           bar ]  };
    key <LSGT>  { [    ugrave,     Ugrave ]     };
    

    While in the file '/usr/share/X11/xkb/symbols/level3' I swapped all appearances of LALT and RALT.

enter image description here

  • The answer here should help you work out how to remap your keys. Ensure you're using instruction that use xkb and not xmodmap. – Dorian Mar 24 '17 at 20:40
  • Thanks for the link. I found the file '/usr/share/X11/xkb/symbols/ca' that contains the canadian Multilingual keyboard layout; I'll try to modify it. – Olivier Mar 24 '17 at 20:50
  • @Dorian: There is no need to edit package owned files in this case. Please see my answer. – Gunnar Hjalmarsson Mar 24 '17 at 22:33
  • take a look at superuser.com/a/1188622/685512 -- does the bug workaround help? – quixotic Mar 24 '17 at 22:36
  • @quixotic: That shouldn't be needed on Ubuntu due to the apple:badmap option. – Gunnar Hjalmarsson Mar 24 '17 at 22:40
1

Editing files owned by the xkb-data package should be avoided, since the changes will be lost if/when the package is updated. And in this case there is a more straightforward way to achieve what you want.

So, the first thing I suggest is that you reset the changes you made by running this command:

sudo apt install --reinstall xkb-data

Then you can use XKB options. To change the behavior in the current session you can run this command:

setxkbmap -option "lv3:lalt_switch,lv3:ralt_alt,apple:badmap"

If that does what you want, you can make the changes persistent by opening the file /etc/default/keyboard for editing and change this line:

XKBOPTIONS=""

to

XKBOPTIONS="lv3:lalt_switch,lv3:ralt_alt,apple:badmap"
  • awesome, didn't know about apple:badmap. – quixotic Mar 24 '17 at 22:34
  • @quixotic: No, unfortunately that option is somewhat hidden. It works in Debian/Ubuntu because of a patch, but not on distros which use the upstream XKB unmodified. – Gunnar Hjalmarsson Mar 24 '17 at 22:37
0

Bad approach (see the other answer)

To swap the left and right alts, access the file '/usr/share/X11/xkb/symbols/level3':

sudo gedit /usr/share/X11/xkb/symbols/level3

and swap the character strings <LALT> and <RALT> everywhere they appear.

To swap the keys corresponding to 'ù' and '/' (for the Canadian Multilingual layout), access the file '/usr/share/X11/xkb/symbols/ca':

sudo gedit /usr/share/X11/xkb/symbols/ca

and swap the contents (what is between the brackets '[' and ']') of the keys <TLDE> and <LSGT>

  • editing these files is unnecessary, especially not the "swap this everywhere" you recommend for level3. please don't recommend this. xkb options can be used to override any troublesome keys. – quixotic Mar 24 '17 at 22:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.