1

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

chicks
  • 572
  • 8
  • 24
Olivier
  • 113
  • 7

2 Answers2

3

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"
Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94
  • 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
  • @GunnarHjalmarsson What if I have 2 keyboards layouts and I switch between them. The swap still occurs. How can I configure only the french canadian one? – Mike Gleason jr Couturier Jan 20 '20 at 15:42
  • @MikeGleasonjrCouturier: Don't know. OTOH, the need to swap ought to be there irrespective of which layout is active (even if you may not consider those keys important enoght when using the other layout). – Gunnar Hjalmarsson Jan 20 '20 at 17: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>

Olivier
  • 113
  • 7
  • 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