Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some media keys cannot be re-assigned because Gnome Settings Daemon maps them statically #376

Open
stan-janssen opened this issue Aug 11, 2021 · 3 comments

Comments

@stan-janssen
Copy link

What Happened

I'm on a desktop computer with one external monitor. I have a keyboard that has brightness up/down keys. I want to assign these keys to a script that I made that send DDC commands to my monitor to change the brightness. This script works fine if I assign, for example, ctrl + brightness up and ctrl + brightness down, but not the brightness up and brightness down keys on their own. The script simply does not run.

brightness

Expected Behavior

I'd like to be able to assign my brightness up and brightness down keys to a custom script.

Steps to Reproduce

To make it simple, let's assign a shortcut key to the command notify-send Hello "This is a test":

  • Open System Settings > Keyboard > Shortcuts > Custom
  • Add a custom shortcut for notify-send Hello "This is a test" with shortcut key MonBrightnessUp.
  • Press the Brightness Up key; the script does not run.
  • Change the shortcut to ctrl + MonBrightnessUp
  • Press ctrl + MonBrightnessUp; the script runs and we see the notification.

brightness-reproduce

Logs

I don't have any logs for this.

Platform Information

ElementaryOS 6 stable. This problem was also present in elementaryOS 5.1.7 that I was using previously.

@sjlua
Copy link

sjlua commented Aug 13, 2021

Can you assign any custom keyboard shortcuts? They don't seem to work for me at all.

@stan-janssen
Copy link
Author

Can you assign any custom keyboard shortcuts? They don't seem to work for me at all.

Yes, all other custom shortcuts work fine for me; see the description in the issue where setting ctrl + Brightness Up works fine. It seems to be that the OS is capturing the Brightness Up and Brightness Down keys and not propagate them to whatever system is handling these custom shortcuts.

@stan-janssen
Copy link
Author

stan-janssen commented Aug 15, 2021

I've found the cause of this problem. Apparently, in Gnome Settings Daemon, there were bindings for the brightness keys named screen-brightness-up-static and screen-brightness-down-static. Once I removed the Brightness keys from these assignments, my custom keyboard shortcuts now work:

gsettings set org.gnome.settings-daemon.plugins.media-keys screen-brightness-up-static "['']"
gsettings set org.gnome.settings-daemon.plugins.media-keys screen-brightness-down-static "['']"

After removing these static shortcuts, it is neccessary to log out and back in again

I've also verified that this solves the problem @sirsleon had in #378 where it was not possible to assign the Tools key; this binding key was already statically bound to control-center-static. To remove this static binding:

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

On could wonder why these static, non-rebindable things exist in the first place. I found this rather heated discussion that got shut down by the maintainers over at the Gnome Settings Daemon issue tracker where people were running into similar problems. Apparently rebinding these statically bound keys will not be supported officially, and apparently is a Bad Idea™; I could not follow why it would be a bad idea to rebind some of these media keys.

The full list of statically-bound keys is:

battery-status-static ['XF86Battery']
calculator-static ['XF86Calculator']
control-center-static ['XF86Tools']
eject-static ['XF86Eject']
email-static ['XF86Mail']
hibernate-static ['XF86Suspend', 'XF86Hibernate']
home-static ['XF86Explorer']
keyboard-brightness-down-static ['XF86KbdBrightnessDown']
keyboard-brightness-toggle-static ['XF86KbdLightOnOff']
keyboard-brightness-up-static ['XF86KbdBrightnessUp']
media-static ['XF86AudioMedia']
mic-mute-static ['XF86AudioMicMute']
next-static ['XF86AudioNext', '<Ctrl>XF86AudioNext']
pause-static ['XF86AudioPause']
playback-forward-static ['XF86AudioForward']
playback-random-static ['XF86AudioRandomPlay']
playback-repeat-static ['XF86AudioRepeat']
playback-rewind-static ['XF86AudioRewind']
play-static ['XF86AudioPlay', '<Ctrl>XF86AudioPlay']
power-static ['XF86PowerOff']
previous-static ['XF86AudioPrev', '<Ctrl>XF86AudioPrev']
rfkill-bluetooth-static ['XF86Bluetooth']
rfkill-static ['XF86WLAN', 'XF86UWB', 'XF86RFKill']
rotate-video-lock-static ['<Super>o']
screen-brightness-cycle-static ['XF86MonBrightnessCycle']
screen-brightness-down-static ['XF86MonBrightnessDown']
screen-brightness-up-static ['XF86MonBrightnessUp']
screensaver-static ['XF86ScreenSaver']
search-static ['XF86Search']
stop-static ['XF86AudioStop']
suspend-static ['XF86Sleep']
touchpad-off-static ['XF86TouchpadOff']
touchpad-on-static ['XF86TouchpadOn']
touchpad-toggle-static ['XF86TouchpadToggle', '<Ctrl><Super>XF86TouchpadToggle']
volume-down-precise-static ['<Shift>XF86AudioLowerVolume', '<Ctrl><Shift>XF86AudioLowerVolume']
volume-down-quiet-static ['<Alt>XF86AudioLowerVolume', '<Alt><Ctrl>XF86AudioLowerVolume']
volume-down-static ['XF86AudioLowerVolume', '<Ctrl>XF86AudioLowerVolume']
volume-mute-quiet-static ['<Alt>XF86AudioMute']
volume-mute-static ['XF86AudioMute']
volume-up-precise-static ['<Shift>XF86AudioRaiseVolume', '<Ctrl><Shift>XF86AudioRaiseVolume']
volume-up-quiet-static ['<Alt>XF86AudioRaiseVolume', '<Alt><Ctrl>XF86AudioRaiseVolume']
volume-up-static ['XF86AudioRaiseVolume', '<Ctrl>XF86AudioRaiseVolume']
www-static ['XF86WWW']

This means that the above keys or key-combinations will not be able to be remapped to something else. It is unclear to me what kind of problem this is trying to prevent, so I'm going to go ahead and propose a solution for this:

  1. We should add all these statically defined keys to the keyboard shortcuts panel, so that they are at least discoverable.
  2. Wherever possible, elemenatryOS should map these statically-bound keys to something logical; I think @sirsleon's suggestion of mapping the Tools key to System Settings is a reasonable example.
  3. Whenever a user wants to re-assign one of these keys that was statically bound, we should display a warning telling the user:
    1. Unexpected behavior may occur
    2. They need to log and and log back in to enable the change

People over at Gnome Settings Daemon and Gnome Control Center have filed several issues where solutions are being proposed but none are being accepted over there:

I will try to work up the above solution to see if this is something that elementaryOS would like to enable.

@stan-janssen stan-janssen changed the title Cannot assign Brightness Up / Down keys Some media keys cannot be re-assigned because Gnome Settings Daemon maps them statically Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants