0

I wanted to utilize keyboard shortcuts Ctrl+Alt+Plus or Minus on the numerical part of the keyboard, but they are not working at all on any Linux I've tried (Manjaro and Debian and both Gnome and KDE).

My settings:

  • Standard full size keyboard
  • NumLock is ON
  • English layout set LANG=en_US.UTF-8

What works fine:

  • Ctrl + Plus
  • Alt + Plus
  • Shift + Plus

But Ctrl+Alt+Plus does nothing in any program where I assign this combination like Krusader, Dolphin, etc.

What I've found (probably the issue)

I tried to run xev and when pressing Ctrl+Alt+Plus or Minus, it gives me this

# For Ctrl+Alt+Plus
KeyRelease event, serial 28, synthetic NO, window 0x6c00001,
    root 0x532, subw 0x0, time 3273638, (977,484), root:(1591,1348),
    state 0x1c, keycode 86 (keysym 0x1008fe22, XF86Next_VMode), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

# For Ctrl+Alt+Minus
KeyRelease event, serial 28, synthetic NO, window 0x6c00001,
    root 0x532, subw 0x0, time 3307298, (904,548), root:(1518,1412),
    state 0x1c, keycode 82 (keysym 0x1008fe23, XF86Prev_VMode), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

So, it seems the Plus/Minus keys are mapped to symbols XF86Next_VMode/XF86Prev_VMode when you have Ctrl+Alt modifiers pressed, while with any other modifier (or none) they are mapped to KP_Add/KP_Subtract.

So, my questions is why it behaves this way and what are these XF86Next_VMode/XF86Prev_VMode supposed to mean?

I'm still a Linux beginner, but I'm used to utilize these shortcuts on Windows, so I wanna use them on Linux as well. I read somewhere you can use xmodmap to remap keycodes to diferent symbols, which I guess could solve my issue.

However when I read about xmodmap on Arch Wiki, I'm still confused. They say

Each keysym column in the table corresponds to a particular combination of modifier keys:

    Key
    Shift+Key
    Mode_switch+Key
    Mode_switch+Shift+Key
    ISO_Level3_Shift+Key
    ISO_Level3_Shift+Shift+Key

but which column is supposed to represent the Ctrl+Alt combination in the above list? Also is it recommended to use the xmodmap to solve this issue?

0

1 Answer 1

0

Eventually I made the shortcuts working using the xmodmap utility.

1. I run xmodmap -pke to see the current mapping for each keycode:

$ xmodmap -pke
...
keycode  82 = KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract XF86Prev_VMode
keycode  86 = KP_Add KP_Add KP_Add KP_Add KP_Add KP_Add XF86Next_VMode
...

We can already see the problem: the last column contains those symbols XF86Next_VMode, XF86Prev_VMode. The 7th column seems to belong to the combination Ctr+Alt. Although I wasn't able to find what the 7th column means in any documentation.

2. Create a file .xmodmaprc in your home directory with this content to fix the 7th column:

keycode  82 = KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract
keycode  86 = KP_Add KP_Add KP_Add KP_Add KP_Add KP_Add KP_Add

3. Run the command xmodmap ~/.xmodmaprc in terminal and the shortcuts should start working for you immediately (until next login).

4. Obviously I wanted to make this fix working every time after login.

First, I tried to add this into the file .profile, which is supposed to be loaded after each login.

if [ -f $HOME/.xmodmaprc ]; then
    sleep 5 && xmodmap $HOME/.xmodmaprc &
fi

Note, I had to add the sleep 5 command, otherwise it didn't work. However, it turned out it works only with KDE and Gnome on X11 display server. When I tried Gnome on Wayland it never worked for some reason (I believe the .profile was loaded, but the xmodmap command failed to execute, why?).

So, I tried another solution and went to the path ~/.config/autostart/, where I created a file with this content:

$ cat ~/.config/autostart/xmodmap.desktop
[Desktop Entry]
Name=Xmodmap
Type=Application
Exec=bash -c "sleep 5 && [[ -f $HOME/.xmodmaprc ]] && xmodmap $HOME/.xmodmaprc"
Terminal=false
Hidden=false

Finally, using the desktop autostart file, I was able to fix the desired keyboard shortcuts for any Linux session I've tried so far.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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