Power Button Enabled To Do Shutdown?

If none of the more specific forums is the right place to ask

Power Button Enabled To Do Shutdown?

Postby shinobi » 2017-08-17 00:32

Power Button Enabled To Do Shutdown? I know Debiain 9 is configured by default for suspend or hibernate. But I want to do a graceful shutdown. Using Debian 9.1, default GUI. I have tried to enable this under systemd-logind configuration does not work. And I know that apcid is legacy and depreciated. Anyone figure this out?

Current /etc/systemd/logind.conf is as follows:

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#UserTasksMax=33%

PowerKeyIgnoreInhibited=no
HandlePowerKey=poweroff

I enabled the PowerKey and PowerKey handle but it does not work apparently. I do see the event invoked in the auth.log, for example:

Aug 16 18:20:56 crazy systemd-logind[1818]: Power key pressed.
Aug 16 18:20:57 crazy systemd-logind[1818]: Power key pressed.

Thanks.
shinobi
 
Posts: 6
Joined: 2017-08-17 00:21

Re: Power Button Enabled To Do Shutdown?

Postby orythem27 » 2017-08-17 00:36

Try configuring in your desktop enviroment power manager first.
User avatar
orythem27
 
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: Power Button Enabled To Do Shutdown?

Postby Bulkley » 2017-08-17 01:12

For Shutdown use
Code: Select all
systemctl poweroff


For Reboot use
Code: Select all
systemctl reboot


I added both to my Openbox menu, the one a right click brings up. You should be able to do something similar on all Linux desktops or WMs.
Bulkley
 
Posts: 5267
Joined: 2006-02-11 18:35

Re: Power Button Enabled To Do Shutdown?

Postby debiman » 2017-08-17 15:54

shinobi wrote:I enabled the PowerKey and PowerKey handle but it does not work apparently.

have you restarted systemd after making changes to the config?
i think it is "systemctl daemon-reload" or some such.
User avatar
debiman
 
Posts: 1191
Joined: 2013-03-12 07:18

Re: Power Button Enabled To Do Shutdown?

Postby shinobi » 2017-08-22 21:48

yes, I did systemctl daemon-reload after the changes.
shinobi
 
Posts: 6
Joined: 2017-08-17 00:21

Re: Power Button Enabled To Do Shutdown?

Postby None1975 » 2017-08-23 12:56

Bulkley wrote:For Shutdown use
Code: Select all
systemctl poweroff


For Reboot use
Code: Select all
systemctl reboot


I added both to my Openbox menu, the one a right click brings up. You should be able to do something similar on all Linux desktops or WMs.

Maybe, better use
Code: Select all
systemctl poweroff -i
The -i argument for systemctl poweroff causes a shutdown even if other users are logged-in (this requires polkit), or when logind (wrongly) assumes so.
OS: Debian 9.1 / WM: Openbox
Debian Wiki | DontBreakDebian
User avatar
None1975
 
Posts: 154
Joined: 2015-11-29 18:23
Location: Lithuania

Re: Power Button Enabled To Do Shutdown?

Postby shinobi » 2017-09-03 03:28

That is, well, not helpful, because I can't get debian to do what Ubuntu,Windows MacOS, all do out of the box. This system will be HEADLESS and LOCAL KEYBOARDLESS and thus I really need the power button to initiate a power down by the OS.

Linux is frustrated in this regard, there is little consistency across distributions at the hardware level. Again, what makes things more confusing is that EVEN AFTER I disable the hibernate or suspect options in the UI (GNOME) in this case, pushing the power button the system still goes into a suspect state. THAT MAKES NO SENSE.

Someone has to have figured this out, no? How many 1000s or 10,000s or more people use Debian?
shinobi
 
Posts: 6
Joined: 2017-08-17 00:21

Re: Power Button Enabled To Do Shutdown?

Postby pylkko » 2017-09-03 05:21

Uhm... as far as I know there has never been a default gui for poweroff. I just searched the repository and found nothing. So could you please indicate exactly what the name of the said package is?

And why on earth are you using such package if you intend to use the machine headless? If there is any such package it will likely ask you to ok the action by clicking on some ok label. What you are saying is extremely confusing, or maybe I am just not understanding what you want.

if what you want is a button or other means to shut down gracefully then why not create a service that send a shutdown signal upon said event?

If you read the manual for logind.conf it says:
PowerKeyIgnoreInhibited=, SuspendKeyIgnoreInhibited=, HibernateKeyIgnoreInhibited=, LidSwitchIgnoreInhibited=

Controls whether actions that systemd-logind takes when the power and sleep keys and the lid switch are triggered are subject to high-level inhibitor locks ("shutdown", "sleep", "idle"). Low level inhibitor locks ("handle-power-key", "handle-suspend-key", "handle-hibernate-key", "handle-lid-switch"), are always honored, irrespective of this setting.

These settings take boolean arguments. If "no", the inhibitor locks taken by applications are respected. If "yes", "shutdown", "sleep", and "idle" inhibitor locks are ignored. PowerKeyIgnoreInhibited=, SuspendKeyIgnoreInhibited=, and HibernateKeyIgnoreInhibited= default to "no". LidSwitchIgnoreInhibited= defaults to "yes". This means that when systemd-logind is handling events by itself (no low level inhibitor locks are taken by another application), the lid switch does not respect suspend blockers by default, but the power and sleep keys do.


To me at least, it reads as if you would want to be using the "yes" bit, however in your conf file that you posted in the first post to this thread, you use "no". Why?

Another possible solution you might want to consider is serving a small webserver that offers (locally) a page with buttons like "poweroff" "reboot" etc, in which case you would not even need to have physical access to the button.

I have one headless server where I placed a shutdown systemd service file and it works. However my version shutsdown automatically after a certain time has passed. But I am sure that what you want can be done. It is possible that if you installed some package to handle this (the gui that you talk of) then that is messing up the configuration some how and maybe you should remove it.
User avatar
pylkko
 
Posts: 1045
Joined: 2014-11-06 19:02

Re: Power Button Enabled To Do Shutdown?

Postby Head_on_a_Stick » 2017-09-03 09:00

Can we please see the full output of
Code: Select all
systemd-inhibit

I don't think the GNOME developers allow shutdown via a power button:

https://unix.stackexchange.com/question ... of-suspend

Plenty of other desktops (and window managers) available though :)
No code is faster than no code.

Please read before posting How to report a problem
User avatar
Head_on_a_Stick
 
Posts: 6536
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Power Button Enabled To Do Shutdown?

Postby debiman » 2017-09-03 16:29

a headless server with a gnome ui? you sure about that?
User avatar
debiman
 
Posts: 1191
Joined: 2013-03-12 07:18

Re: Power Button Enabled To Do Shutdown?

Postby Head_on_a_Stick » 2017-09-03 16:34

^:
shinobi wrote:Using Debian 9.1, default GUI.

But maybe you're right, the `systemd-inhibit` output will show for sure anyway.
No code is faster than no code.

Please read before posting How to report a problem
User avatar
Head_on_a_Stick
 
Posts: 6536
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Power Button Enabled To Do Shutdown?

Postby debiman » 2017-09-03 16:44

^ no, that snark was directed at op.
i just don't see the point in discussing inconsistencies in ui design in linux, then saying that the whole point of the discussion is about being able to poweroff a headless server... which shouldn't be running a gui anyway, imho.
getting rid of the gui, letting systemd handle the power button => benefit.
User avatar
debiman
 
Posts: 1191
Joined: 2013-03-12 07:18

Re: Power Button Enabled To Do Shutdown?

Postby GarryRicketson » 2017-09-03 18:18

Post by shinobi » 2017-09-02 21:28
That is, well, not helpful, because I can't get debian to do what Ubuntu,Windows MacOS, all do out of the box. This system will be HEADLESS and LOCAL KEYBOARDLESS and thus I really need the power button to initiate a power down by the OS.

Maybe it would be better for this OP to just use those ?
Because Debian is not like the others , fortunately.

I really need the power button to initiate a power down by the OS.

No you don't, or you shouldn't need that.
So why can't the OP just access via ssh, and shut it down that way ?
That is what I do.
User avatar
GarryRicketson
 
Posts: 4215
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Power Button Enabled To Do Shutdown?

Postby debiman » 2017-09-08 05:05

GarryRicketson wrote:
I really need the power button to initiate a power down by the OS.

No you don't, or you shouldn't need that.
So why can't the OP just access via ssh, and shut it down that way ?
That is what I do.

thanks, garry, for bringing me back down on the ground.
you're absolutely right.
i never touch my server, gui or not. keyboard's way too dusty by now.
come to think of it, i also don't power it off (unless there's a very serious problem).
reboot, yes.
User avatar
debiman
 
Posts: 1191
Joined: 2013-03-12 07:18

Re: Power Button Enabled To Do Shutdown?

Postby RickyTerzis » 2017-09-12 16:31

Hi..i am a new user here. As per my knowledge there is little consistency across distributions at the hardware level. What makes things more confusing is that EVEN AFTER I disable the hibernate or suspect options in the UI in this case, pushing the power button the system still goes into a suspect state.
RickyTerzis
 
Posts: 1
Joined: 2017-09-12 16:10

Next

Return to General Questions

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable