You are not logged in.

#1 2016-11-08 10:54:17

remus
Member
Registered: 2015-11-03
Posts: 33

How can I disable the "Suspend" button on my keyboard?

Hi all,

I'm using Arch Linux with Gnome 3 and Xorg on a desktop PC. My keyboard comes with a button for suspending, and something in my system's configuration seems hell-bent on making it do that, no matter what I try to change that, and no matter where I disable hibernating/suspending (I don't know which of those it is, but I don't want either). It even suspends when I try to set a shortcut for the key, or press it in other context when no other shortcut key does anything.

Which would all not be that much of a problem if suspending worked reliably in Linux, but of course it doesn't, so each time I accidentally touch that button, I need to do a hard reboot and lose about ten minutes of my time. Which is getting annoying enough that I finally want to resolve this – hence this thread.

I've of course already googled, but couldn't really find something that worked for me. There was something about Polkit, but they seem to have completely changed their syntax so those tips don't apply anymore, and "xve" for finding out the key code and then disabling that on the hardware side, but that would of course suspend the PC as soon as I press the key, so I hope there's an easier way.

Does anyone have any tips?
Thanks a lot in advance!

Last edited by remus (2016-11-08 10:54:34)

Offline

#2 2016-11-08 11:34:18

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: How can I disable the "Suspend" button on my keyboard?

remus wrote:

no matter what I try to change that, and no matter where I disable hibernating/suspending

What have you tried?  What have you disabled?  Have you editted logind.conf?

Are you sure suspending doesn't work?  Do you have a resume button?  Sometimes this is a 'Fn' key in the lower left of laptop keyboards.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2016-11-08 11:46:37

remus
Member
Registered: 2015-11-03
Posts: 33

Re: How can I disable the "Suspend" button on my keyboard?

Thanks for your reply!

Trilby wrote:

What have you tried?  What have you disabled?  Have you editted logind.conf?

Sorry, but last time I tried has been a while, so I don't recall exactly. But I think I just went through all settings and tweak tool screens in the GUI and deactivated anything saying something about suspending or hibernating. I don't think I touched any config files for this – since I couldn't figure out what to change where.

Are you sure suspending doesn't work?  Do you have a resume button?  Sometimes this is a 'Fn' key in the lower left of laptop keyboards.

I wasn't aware there might be a specific button needed for resuming. I just tried some keyboard keys, the mouse and the computer's power button on the case, and finally hit the reset button on the case since nothing else worked.

Offline

#4 2016-11-08 11:56:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: How can I disable the "Suspend" button on my keyboard?

remus wrote:

I couldn't figure out what to change where.

Logind.conf is at /etc/systemd/logind.conf

It's a short file, and the contents are pretty self explanatory.  The commented lines show the default settings.  If you want to change a setting (which you do) uncomment the line and change the part after the equal sign.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2016-11-08 13:14:55

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: How can I disable the "Suspend" button on my keyboard?

"xev", not "xve" - and there's likely no way around that, BUT the button might be a "real" power button.
Check the output of "xinput" - you may try to "xinput disable <id>" inputs and check for the impact. (If you hit your actual keyboard, ensure to have "; sleep 20; xinput enable <id>" appended so you auto-get-back the input device after 30 seconds ;-)

Online

#6 2016-11-08 15:46:45

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,740

Re: How can I disable the "Suspend" button on my keyboard?

What type of keyboard is this?  Is this a laptop with a built in keyboard? If so, it might not actually generate a scancode, but might actually generate direct input to an ATX power supply.
Edit: Does it suspend if you are just running from the console?  (No Xorg or Wayland session running.)

Last edited by ewaller (2016-11-08 15:47:40)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2016-11-08 17:56:06

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: How can I disable the "Suspend" button on my keyboard?

Er ... aren't we getting a bit sidetracked?  The OP checked all the X11 keybinding and didn't find anything relevant.  But they have *not* modified logind.conf.  The default settings of logind.conf suspend the machine when the suspend button is pressed: x11 and xev events are irrelevant.  The OP most likely just needs to modify logind.conf and log back in.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2016-11-08 17:58:21

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: How can I disable the "Suspend" button on my keyboard?

But it's a desktop PC and I assume he'd like to be able to still use the power button on the box?

Online

#9 2016-11-08 18:51:38

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: How can I disable the "Suspend" button on my keyboard?

How is that relevant?  There is a suspend button.  Systemd/logind suspends the system when this button is pressed.  The OP wants to change this behavior.  X11 is not relevant to any of that.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#10 2016-11-08 19:18:21

fluxboxer
Member
Registered: 2012-12-02
Posts: 118

Re: How can I disable the "Suspend" button on my keyboard?

If it's really a power button without scancode, as suggested by Trilby, editing logind.conf might/should help, but if xev or showkey produces a keycode then you need to just change the corresponding keycode line in /usr/share/X11/xkb/symbols/inet.

Let's say, showkey produces 161, then you need to search for 169 in /usr/share/X11/xkb/symbols/inet (add 8 to showkey outputs). xev produces directly the correct keycode, 169, I guess.

I've changed my apple keyboard's eject key (XF86Eject) to XF86_Switch_VT_2 to use it to change to tty2 by replacing the line containing 169

key <I169>   {      [ XF86Eject             ]       };

to

key <I169>   {      [ XF86_Switch_VT_2             ]       };

Obviously, you need to repeat this when an update renews that file.

Last edited by fluxboxer (2016-11-08 19:22:34)

Offline

#11 2016-11-10 14:34:08

remus
Member
Registered: 2015-11-03
Posts: 33

Re: How can I disable the "Suspend" button on my keyboard?

Sorry for the delay in getting back. I did the modifications to logind.conf, but then didn't want to test it until I wanted to shutdown anyways and promptly forgot twice in a row.
I now remembered, but sadly it didn't work. (I also think I remember already trying this once, but apparently it was before my last re-install of the system.) Pressing the key still hibernated the PC. This time, though, resuming DID work. But still not really reliable enough to keep this enabled, if I can help it.

As mentioned in the OP, it's a desktop PC with attached USB keyboard, not a laptop with built-in keyboard.

Yes, "xve" was a typo, sorry.

I now tried pressing the button with "xev" running, and I think this is the relevant output (not 100% sure, though):

KeyPress event, serial 38, synthetic NO, window 0xc00001,
    root 0x4d1, subw 0x0, time 20327749, (1032,490), root:(1097,617),
    state 0x10, keycode 151 (keysym 0x1008ff2b, XF86WakeUp), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 38, synthetic NO, window 0xc00001,
    root 0x4d1, subw 0x0, time 20327749, (1032,490), root:(1097,617),
    state 0x10, keycode 151 (keysym 0x1008ff2b, XF86WakeUp), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

So, keycode 151, it seems.
As per the post where I found this I now did "xmodmap -e 'keycode 151 = NoSymbol'".
Let's try it out …

Last edited by remus (2016-11-10 14:35:43)

Offline

#12 2016-11-10 14:37:39

remus
Member
Registered: 2015-11-03
Posts: 33

Re: How can I disable the "Suspend" button on my keyboard?

Damn, still no dice. :-/ (From the post, it seems restarting is not necessary – or, in fact, even removes the modification.)

The advice from #10 seems a bit dangerous, with its editing such a deeply nested config file. Is there no other way to disable that key? (Especially one that I don't have to remember every time I update a certain package.)

Offline

#13 2016-11-10 14:39:34

remus
Member
Registered: 2015-11-03
Posts: 33

Re: How can I disable the "Suspend" button on my keyboard?

On a console screen (say, after Alt+F3), the key does nothing. It does seem to be caused by Gnome or Xorg. (No Wayland there.)

Offline

#14 2016-11-10 16:06:48

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: How can I disable the "Suspend" button on my keyboard?

If whatever it grabs (if) grabs the code  rather than the symbol, altering the symbol has no direct impact.

First check whether anything actually holds as passive grab, run

xdotool key "XF86LogGrabInfo"

and check the Xorg log for the key (it also says which client grabs it)

If there's no grab, notice that logind oc. requires an active login, ie. if you're not logged into VT3, it won't trigger anything there.

Online

#15 2016-11-11 08:39:07

remus
Member
Registered: 2015-11-03
Posts: 33

Re: How can I disable the "Suspend" button on my keyboard?

seth wrote:

If whatever it grabs (if) grabs the code  rather than the symbol, altering the symbol has no direct impact.

First check whether anything actually holds as passive grab, run

xdotool key "XF86LogGrabInfo"

and check the Xorg log for the key (it also says which client grabs it)

I assume I should use "XF86WakeUp" instead of "XF86LogGrabInfo" in that line?
Anyways, I tried both, but nothing happened. I looked it up afterwards and it seems it would have suspended the PC otherwise? Would have been nice to warn me of that. (Guess I shouldn't just more or less blindly type all commands here.)

So, I guess, the question is then whether I can just block a certain keycode? Or, alternately, how I can find out which system component listens to that keycode and how I can stop it from doing that.

If there's no grab, notice that logind oc. requires an active login, ie. if you're not logged into VT3, it won't trigger anything there.

What does that mean? Am I "logged into VT3" in a normal Xorg/Gnome session?

Last edited by remus (2016-11-11 08:40:10)

Offline

#16 2016-11-11 08:45:40

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: How can I disable the "Suspend" button on my keyboard?

No, "XF86LogGrabInfo" - it prints stuff into your Xorg log (resides in /var/log or ~/.local/share/xorg)
(And since it would not suspend, there was no reason to war you ;-)

Pressing Ctrl+Alt+F3 got you a VT login. You need to login there in order to invoke logind (and reasonably check whether the suspend key works there this way)

Online

#17 2016-11-11 09:16:13

remus
Member
Registered: 2015-11-03
Posts: 33

Re: How can I disable the "Suspend" button on my keyboard?

seth wrote:

No, "XF86LogGrabInfo" - it prints stuff into your Xorg log (resides in /var/log or ~/.local/share/xorg)
(And since it would not suspend, there was no reason to war you ;-)

Ah, sorry then! But I'd tried that, too, and the key still wasn't in the log (neither symbol nor keycode).

Pressing Ctrl+Alt+F3 got you a VT login. You need to login there in order to invoke logind (and reasonably check whether the suspend key works there this way)

Ah, OK. Well, as mentioned above, in that terminal the key didn't work anymore. (Not sure whether it was because of that change, though – didn't try that before.) But that's pretty useless for me, I want it to not work in my normal GUI session.

Offline

#18 2016-11-12 03:01:28

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: How can I disable the "Suspend" button on my keyboard?

Might I suggest a low-tech solution? Why not just pry that key off of your keyboard? No chance of pushing it by accident in that case.

Offline

#19 2016-11-12 08:08:55

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: How can I disable the "Suspend" button on my keyboard?

remus wrote:

But I'd tried that, too, and the key still wasn't in the log (neither symbol nor keycode).

But you had a list of key grabs there (ie. were not looking at a dated log)?

If it's not grabbed by any client (supported by xdotool doesn't "fake" it) and is not the logind feature (tried despite the behavior on the non-graphical login?) I can only think of gdm (try another DM or startx) or "something" scanning raw/xinput2 events.
For the latter, check the behavior in eg. xfce or something and start killing gnome daemons until the behavior stops.

What's even more weird is that out of all keys XF86**WakeUp** causes this ...

Online

#20 2016-11-12 09:18:32

remus
Member
Registered: 2015-11-03
Posts: 33

Re: How can I disable the "Suspend" button on my keyboard?

ataraxia wrote:

Might I suggest a low-tech solution? Why not just pry that key off of your keyboard? No chance of pushing it by accident in that case.

Unconventional solution, but actually worth thinking about, I guess. It's just pretty ugly, and would also rob me of a key I could otherwise re-assign to some handier function.
(Also, it's not a normal key, so I'd have to try how easy it even is to pry out.)

seth wrote:

But you had a list of key grabs there (ie. were not looking at a dated log)?

Yes, lots of grabs listed there, just not for XF86WakeUp or 151.

seth wrote:

If it's not grabbed by any client (supported by xdotool doesn't "fake" it) and is not the logind feature (tried despite the behavior on the non-graphical login?) I can only think of gdm (try another DM or startx) or "something" scanning raw/xinput2 events.
For the latter, check the behavior in eg. xfce or something and start killing gnome daemons until the behavior stops.

If one of those finds the solution, would that help me disable the behavior in my normal Gnome session, or would I have to switch display manager?
The whole thing isn't important enough to switch display/window manager or other such things over it. (I'd rather just pry the key off in that case.)

My real hope was that some expert here would say, "Ah, yes, that's X implementing that, just change Y in config file Z and it should go away." I didn't suspect it would be so mysterious for everyone else here, too.

seth wrote:

What's even more weird is that out of all keys XF86**WakeUp** causes this ...

Yeah, pretty weird name for it. Also, the key looks more like it would turn the PC off, not suspend it (second key from the right in the top-most row). But it does the same under Windows (iirc).

Offline

#21 2016-11-12 13:44:46

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: How can I disable the "Suspend" button on my keyboard?

Well, should we figure it's handled by gdm, it's pointless to look at what of the session causes it (and it might be configurable there)
As long as we don't know what really reacts to the key, we certainly won't turn that off - Elementary, dear Watson ;-)

Online

#22 2016-11-14 08:48:20

remus
Member
Registered: 2015-11-03
Posts: 33

Re: How can I disable the "Suspend" button on my keyboard?

Tried LightDM, no luck.
When I switch to xfce, how do I "start killing gnome daemons"? Just "ps aux | grep gnome" and then "kill"? Any special recommendations?

Offline

#23 2016-11-14 13:55:35

teateawhy
Member
From: GER
Registered: 2012-03-05
Posts: 1,138
Website

Re: How can I disable the "Suspend" button on my keyboard?

Have you  checked /etc/systemd/logind.conf ? HandleSuspendKey

Offline

#24 2016-11-14 15:49:41

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: How can I disable the "Suspend" button on my keyboard?

There should be no gnome daemon running under xfce.
*Iff* it however behaves the same under xfce and gnome, it is *really* likely comments #4 and #23 - despite your apparent findings in comment #17.

Online

#25 2016-11-14 16:02:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: How can I disable the "Suspend" button on my keyboard?

While I really suspected logind.conf was the culprit, the OP said they already checked that:

remus wrote:

I did the modifications to logind.conf

However, to be 100% sure, Remus, if you could post the content of your logind.conf file here that would help.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB