I just tried this, and had kinda the same problem:
I can set the keybindings, but when I press the key, it opens my calculator instead of whatever I told it to do.
I was able to find that this is caused by a program called gsd-media-keys
located at /usr/libexec/gsd-media-keys
(if yours is not there, you can find it with ps -ef | grep gsd-media
, though I don't think the location matters). You can see it working by running sudo journalctl -fe
and then pressing the key:
Nov 12 20:34:29 Node-64 systemd[2009]: Started app-gnome-thunderbird-14449.scope - Application launched by gsd-media-keys.
Nov 12 20:34:58 Node-64 systemd[2009]: Started app-gnome-org.gnome.Calculator-14227.scope - Application launched by gsd-media-keys
As far as I could understand, normal keystrokes are sent to the application currently in focus, but multimedia keys are captured by gsd-media-keys
, and then based on the way it is configured(for example All Running Media Players, The Last One Opened or Currently Playing) it will send some kind of a signal to the required application(s). You can actually see that:
- Install
evtest
.
- Run
sudo evtest
.
- Select your keyboard from the menu .
- If you have a second monitor, put the terminal over there.
- Use your keyboard a bit, you should see a lot of text get printed on the screen, stating every key that was pressed or released.
# example pressing the dot "." key
Event: time 1731432379.487057, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70037
Event: time 1731432379.487057, type 1 (EV_KEY), code 52 (KEY_DOT), value 1
Event: time 1731432379.487057, -------------- SYN_REPORT ------------
Event: time 1731432379.566978, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70037
Event: time 1731432379.566978, type 1 (EV_KEY), code 52 (KEY_DOT), value 0
Event: time 1731432379.566978, -------------- SYN_REPORT ------------
- Press the media key (like open calculator) and you won't see anything get printed stating the pressed key.
To fix this(again, as far as I understood), you should capture the signal for that key from your keyboard with another application, then bind it to another key in that application(some unused key, for example F13), and then make your shortcuts in the settings app using that; Or you could just directly bind it to the multimedia keys for controlling volume if you need them for that.
I don't have enough time right now to test it and write a full walkthrough, so I'll link you to the post I found do this: Map media keys (Volume up/down) to custom actions
Here are other resources I found; They might come in handy for similar problems:
What is `gsd-media-keys`? - Unix Stackexchange
Multimedia keys sometimes stop working - Aks Ubuntu
Map media keys (Volume up/down) to custom actions - Ask Ubuntu
Help To Remap Home Key To Media Key - Linux Mint Forums
Keyboard key handling blocking some multimedia keys? - Ubuntu Budgie discourse
I hope this helps.