4

Ubuntu 20.04.1, Gnome 3.36.3, XOrg 7.7, fresh install on an HP laptop computer (17-by1xxx).

This laptop keyboard does not have a Menu key (ie. a key that activates a context menu in an application - such as would occur from a right button mouse click). I would like to set the right Alt key (this keyboard has both a left and right Alt key) to act in this capacity.

I have done a number of searches of Google, and turned up a number of potential "solutions", but most of them seem to be for older versions of Ubuntu (back in the 11.04 and 12.04 days), or they are specific to Unity, or the methods listed seem to be unusable (or, at the very least, deprecated) in 20.04.

I have found the Gnome-Tweak-Tool, and the "Additional Layout Options" menu, but I apparently lack understanding of what some of these options mean and what effect they would have.

So, my questions:

  1. Is there a "kindergarten" level discussion of what all the options shown in "Additional Layout Options" mean (in more detail than just the phrase that accompanies the option itself), and if so, where might one find this?

  2. Is there an option hiding in the Additional Layout Options that will allow me to use the right Alt key as a Menu key (I found an option to make Caps Lock a Menu key, but I hit Caps Lock accidentally far too often to make that a useful choice").

I have looked (briefly) at the xKeyboard-config file, but I was out of my depth pretty quickly (I am a fairly "novice" user, and not familiar with all the "behind the scenes" things that go on here), so a more verbose discussion of how all this fits together would be appreciated - although a simple "do this, then this, then this..." would work for me for now.

I also spent some time looking at xmodmap, but if I understand this correctly, this affects only the current session and would therefore need to be run each time the system restarts (which could be done using a script that runs at login)? I also found a few places that mentioned that this is somewhat processor intensive, and that it can be affected by locking and unlocking the computer (or perhaps I'm conflating this with setxkbmap - it has been a long day so far, and I should really approach this when I am fresher)...

In any event, any and all help (including pointers to background reading material) is appreciated.

EDIT:

Thanks to UnKNOWn for the assistance. I was able to use xmodmap to change the Right-Alt behavior. I ended up using Shift+Right-Alt, and it works fine. The actual steps I used, which are a slight modification on UnKNOWn's instructions are:

# Get the original key assignments, in case we want to go back
xmodmap -pke
# Find key 108 in the list
# In my case, it is:
#     keycode 108 = Alt_R Meta_R Alt_R Meta_R
# Modify that to produce the menu key effect desired
#     keycode 108 = Alt_R Menu Alt_R Meta_R
# Send it back to xmodmap to test it
xmodmap -e "keycode 108 = Alt_R Menu Alt_R Meta_R"

Adding that final line to the startup apps (whether directly or by saving it in a script and adding the script) solves my problem.

Thanks again, UnKNOWn.

Tracy
  • 495

1 Answers1

2
  1. you can run this command man xkeyboard-config or visit this manpage https://manpages.ubuntu.com/manpages/xenial/man7/xkeyboard-config.7.html and see the possibilities.

  2. If nothing found in the manpage, nothing is hidden.

to make Right Alt as Menu key, based on your session x11 or Wayland.
you can find out which session type by running below command.

echo $XDG_SESSION_TYPE

Example:

[admin@ADMIN ~]$ echo $XDG_SESSION_TYPE
x11
[admin@ADMIN ~]$ 

If its x11 you can use xmodmap config to make Right Alt as Menu key. https://manpages.ubuntu.com/manpages/focal/man1/xmodmap.1.html

if it is Wayland, you need to make a hardware level change https://manpages.ubuntu.com/manpages/focal/man7/hwdb.7.html

There are already answers how to use xmodmap and hwdb if you search in the same AU.

Edit:

for xorg..

First open gnome-tweaks > keyboard and mouse > additional layout options > key to choose 3rd level and untick Right Alt.

create a file with below command.

gedit .xmodmaprc

copy paste below content in the above file.
run xev | grep keycode command and then press right alt to get they keycode and change if it is different from 108.

remove mod1 = Alt_R
keycode 108 = Menu

to apply the above changes immideately, run below command

xmodmap .xmodmaprc

add the command xmodmap .xmodmaprc to startup applications list.

As you mentioned in the Question, if you are not satisfied with the xmodmap, you can go with hwdb https://manpages.ubuntu.com/manpages/focal/man7/hwdb.7.html change which is persistent from boot and dont need anyother scripts or startup commands..