2

I want my Alt Gr key to act the same way as the Alt key. I've found a potential solution which is to open up terminal and run the following commands:

xmodmap -e "clear mod5"
xmodmap -e "keycode 108 = Alt_L"

This solution works but only temporarily. Whenever I restart the computer it reverts back or even if I'm using my laptop for a few hours the fix is undone.

I'm wondering if their is a permanent solution to this issue.

Just a little about me, I've only started using ubuntu in the last few months so I'm very inexperienced with it so I apologise in advance if I have follow up questions for any potential solutions.

Many thanks

Artur Meinild
  • 26,018
user207489
  • 53
  • 1
  • 5
  • Does this help? http://askubuntu.com/questions/254424/how-can-i-change-what-keys-on-my-keyboard-do-how-can-i-create-custom-keyboard/300203#300203 – Mitch Nov 10 '13 at 17:35

1 Answers1

4

To get this change permanently for every session, create a file called .xmodmap with the the current keymap table, using the following command (after you have run previously xmodmap -e "clear mod5" and xmodmap -e "keycode 108 = Alt_L"):

xmodmap -pke > ~/.xmodmap

Then, create a file called .xinitrc in your home directory (using touch ~/.xinitrc command), containing the following line/command (use gedit ~/.xinitrc command to open the file for editing):

xmodmap .xmodmap

Another solution is to run:

sh -c 'xmodmap -e "clear mod5"; xmodmap -e "keycode 108 = Alt_L"'

command to your startup applications and that'll run it when you log in. Search in Dash for "startup applications".

Radu Rădeanu
  • 169,590
  • Thank you for the answer, just to confirm, where exactly do I save the file? – user207489 Nov 10 '13 at 17:50
  • @user207489 In your home directory: /home/your_username. – Radu Rădeanu Nov 10 '13 at 17:52
  • 1
    Hi, tried this and it didn't seem to work. Here is exactly what I did so you can see where I'm going wrong. I opened the terminal and ran the two previous commands. I then ran xmodmap -pke > .xmodmap. I then went to home directory, right clicked and created new document, named it .xinitrc and copied xmodmap .xmodmap into the document and saved it. Restarted and unfortunately it hasn't carried through. Any thoughts? Many thanks for your continued help aswell – user207489 Nov 10 '13 at 17:58
  • @user207489 Now what is the output of cat ~/.xmodmap | grep Alt_L ? – Radu Rădeanu Nov 10 '13 at 18:05
  • Output is keycode 64 = Alt_L Meta_L Alt_L Meta_L keycode 108 = Alt_L NoSymbol Alt_L keycode 204 = NoSymbol Alt_L NoSymbol Alt_L – user207489 Nov 10 '13 at 18:06
  • @user207489 It looks ok. And the output of cat ~/.xinitrc? – Radu Rădeanu Nov 10 '13 at 18:12
  • Returns with: xmodmap .xmodmap However, still not working following restart I'm afraid. – user207489 Nov 10 '13 at 18:14
  • So, you made everything good... It should work after restart. – Radu Rădeanu Nov 10 '13 at 18:24
  • After reboot problem still persists. Thank you for your help anyway – user207489 Nov 10 '13 at 18:30
  • @user207489 Another solution is to run sh -c 'xmodmap -e "clear mod5"; xmodmap -e "keycode 108 = Alt_L"' command to your startup applications and that'll run it when you log in. Search in Dash for startup applications. – Radu Rădeanu Nov 10 '13 at 18:41
  • That worked perfect. Thank you so much for your help – user207489 Nov 10 '13 at 18:48