1

I'm using GNOME 3.20 (on Archlinux, with systemd and no acpid). 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 gnome-session-quit --power-off.

I tried to set org.gnome.settings-daemon.plugins.power to 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.

Thanks

  • Unless you're willing to patch the source code, (as I said here) no, I don't think there's another way. – don_crissti Jun 19 '16 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.