I’m on Gnome 50.4 via Fedora 44 and have a wireless Apple keyboard. One of the corner buttons on this keyboard is the Media Eject key. Every time I accidentally hit the key it unmounts my SD Card and I can’t access it again until I pop the SD Card out, pop it back in, and then remount it in Nautilus. When the Media Eject key is hit, is there a way to prevent my SD Card from being ejected or disable the Media Eject key altogether?
IDK that GNOME has integrated options to ignore or remap keys. This is likely configured at the OS level and thus better asked in Fedora support.
If Fedora works anything like Arch Linux you’d use sudo evtest to get the scan code for that key then put a hwdb file in /etc/udev/hwdb.d/ to disable that key (set it to ‘reserved’), or use setkeycodes command for the same. See: Map scancodes to keycodes - ArchWiki
Run gsettings set org.gnome.settings-daemon.plugins.media-keys eject-static "['']" and restart your session afterwards.
I tried gsettings set org.gnome.settings-daemon.plugins.media-keys eject-static "['']" and after rebooting the machine the problem was still there.
UPDATE: Also tried gsettings set org.gnome.settings-daemon.plugins.media-keys eject "['']"
UPDATE2: Seems to be by design *-static media-keys bindings interfere with keyboard shortcut customisations (#466) · Issues · GNOME / gnome-settings-daemon · GitLab
Following the guide for udev worked:
- Map scancodes to keycodes - ArchWiki Following this guide
- Keyboard input - ArchWiki Using
evtestto find scancode - udev - ArchWiki Modying the
hwdbto disable the key
That’s not what’s stated in the issue. The issue is about those static keybindings not being considered for conflicts when assigning custom keybindings in gnome-control-center. Being able to unset static keybindings is something that is expected to work (after a session restart) and also mentioned as working in the linked issue. Not sure why it wasn’t working for you. Maybe you ran the command as wrong user?
Possibly, should I run it as root?
Running the command as regular user is correct. Maybe you can test if it is actually gsd-media-keys that is triggering the eject by temporarily stopping the process: Run pkill -STOP gsd-media-keys and try pressing the key, if that still ejects, it’s probably something else that is unmounting stuff. Afterwards run pkill -CONT gsd-media-keys to resume the process again.
I can confirm that gsd-media-key is the process controlling it. When I suspend the process it stops the key from working. When I resume it, the eject happens.
What is the output of gsettings get org.gnome.settings-daemon.plugins.media-keys eject-static now?
> gsettings get org.gnome.settings-daemon.plugins.media-keys eject-static
['XF86Eject']
It is the default value because I ran a reset on it a few day ago.
Can you try changing the value again, reboot and then check again? Just want to make sure the setting was actually changed properly and there is no issue on that side.
After setting it and then rebooting, the eject functionality still triggers and unmounts my SD Card.
/etc/udev/hwdb.d ro 0s
> gsettings get org.gnome.settings-daemon.plugins.media-keys eject-static
['']
/etc/udev/hwdb.d ro 0s
>
UPDATE: If you are curious about my scancode:
/etc/udev/hwdb.d ro 0s
> cat 90-disable-bt-apple-keyboard-eject.hwdb
evdev:input:b0005v004Cp0267e0206*
KEYBOARD_KEY_C00B8=reserved # Disable eject key on Apple Magic Keyboard
/etc/udev/hwdb.d ro 0s
>
Is gsettings get org.gnome.settings-daemon.plugins.media-keys eject still empty after a session restart? There seems to be some migration code that might end up writing that setting when gsd-media-keys is started, i.e. after a session restart.
Yes, that value remains empty.
> gsettings get org.gnome.settings-daemon.plugins.media-keys eject
['']
~ 0s
> gsettings get org.gnome.settings-daemon.plugins.media-keys eject-static
['']
~ 0s
>
I tried emulating a keyboard with such a key locally and everything works as expected here. In the initial configuration I see the eject OSD popping up when I “press” the eject key and when I set eject-static to something empty, it stops after a session restart.
Do you know when Gnome transforms from key to action? Doesn’t seem like the do_action function in settings-daemon does any filtering of the eject key. Was glancing over to see if anything jumped out at me: gnome-settings-daemon/plugins/media-keys/gsd-media-keys-manager.c at bf7df43430cb11c1d83b3aa1fb3c9405a3a6f302 · GNOME/gnome-settings-daemon · GitHub
It generates a list of bindings from shortcuts-list.h and then registers grabs for these in gnome-shell. Most of the relevant code is in the file you linked.
Do you know how to see or enable the output of g_debug() calls? Not seeing them show up in journalctl to see if I see anything interesting there.
That can be controlled by the G_MESSAGES_DEBUG environment variable of the process. Setting it to all should give you all messages.