I'm using GNOME 3.20 (on Archlinux, with
systemd and no
Since GNOME only allows three options as actions for when pressing the power button (hibernate, sleep, or nothing), i'd like to execute a custom command when the keyboard power button is pressed.
The command would be
I tried to set
nothing and set a custom media key (keyboard shortcut) on the keyboard power button to do so, but nothing happens when i press the button. (When i set custom media keys with keys other than PowerButton, it works).
I also tried to write a GNOME Shell Extension adding a custom key binding through the
Main.wm.addKeybinding function, but also here, nothing happens when the key is set to PowerButton, but it works perfectly with other keys.
A solution would be to capture global keyboard events directly in the extension and not use
Main.wm.addKeybinding, but i did not find anything to do so.
Does anyone have a solution? Preferably, not involving recompiling
gnome-settings-daemon, because i tried that a couple times and it was too ugly.