9

My lenovo Laptop has a short-cut for to open a calculator.

Since I don't use this, I want to use this key for a different action.

But if I try to add a new shortcut, the calculator opens. It seems, I can't create a new shortcut for this key.

change-shortcut-for-calculator

The key which I would like to start my own script:

lenovo-calculator-key

I am using Ubuntu 20.04

guettli
  • 1,777

1 Answers1

4

I did it on Ubuntu 20.04
Thanks to Zatigem's answer on a question about the Sleep button

I found it by chance so maybe it helped that I started by disabling "start the calculator" in Ubuntu Shortcuts, as well as

$ gsettings set org.gnome.settings-daemon.plugins.media-keys calculator-static "['']"

Let's find the code

$ xmodmap -pk | grep -i calc
    148     0x1008ff1d (XF86Calculator) 0x0000 (NoSymbol)   0x1008ff1d (XF86Calculator)

Edit /usr/share/X11/xkb/keycodes/evdev as root.
Comment the line containing the number you saw (148 for me) by adding // at the beginning

 // <I148> = 148;   // #define KEY_CALC                140

Restart the gnome GUI (you won't lose any open app):
Press Alt+F2, type the letter r, press Enter

gnome takes some seconds to come back to normal.
Now pressing the Calc button does nothing, but you can't use anymore in shortcuts.
So let's re-enable it, by editing again the evdev file and removing the // we put.
Restart gnome GUI again.
Now the Calc button does nothing and you can use it in shortcuts.

(I'm not sure all the steps are necessary, and if it still works after reboot.)

lolesque
  • 521
  • Probably best not to be editing stuff in /usr - it may be overridden by the system later. FWIW, in 23.04 I banged into this issue AGAIN. It's never ending. But you put me on the right track: use gsettings to remove the key binding as you say. Reload gnome, as you say. Then use the ubuntu settings screen to add a custom shortcut. – Aaron Jun 22 '23 at 05:25