Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Power Button Enabled To Do Shutdown?

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
shinobi
Posts: 14
Joined: 2017-08-17 00:21

Power Button Enabled To Do Shutdown?

#1 Post by shinobi »

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.

User avatar
orythem27
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: Power Button Enabled To Do Shutdown?

#2 Post by orythem27 »

Try configuring in your desktop enviroment power manager first.

Bulkley
Posts: 6383
Joined: 2006-02-11 18:35
Has thanked: 2 times
Been thanked: 39 times

Re: Power Button Enabled To Do Shutdown?

#3 Post by Bulkley »

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.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Power Button Enabled To Do Shutdown?

#4 Post by debiman »

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.

shinobi
Posts: 14
Joined: 2017-08-17 00:21

Re: Power Button Enabled To Do Shutdown?

#5 Post by shinobi »

yes, I did systemctl daemon-reload after the changes.

User avatar
None1975
df -h | participant
df -h | participant
Posts: 1388
Joined: 2015-11-29 18:23
Location: Russia, Kaliningrad
Has thanked: 45 times
Been thanked: 65 times

Re: Power Button Enabled To Do Shutdown?

#6 Post by None1975 »

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 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github

shinobi
Posts: 14
Joined: 2017-08-17 00:21

Re: Power Button Enabled To Do Shutdown?

#7 Post by shinobi »

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?

User avatar
pylkko
Posts: 1802
Joined: 2014-11-06 19:02

Re: Power Button Enabled To Do Shutdown?

#8 Post by pylkko »

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
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Power Button Enabled To Do Shutdown?

#9 Post by Head_on_a_Stick »

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 :)
deadbang

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Power Button Enabled To Do Shutdown?

#10 Post by debiman »

a headless server with a gnome ui? you sure about that?

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Power Button Enabled To Do Shutdown?

#11 Post by Head_on_a_Stick »

^:
shinobi wrote:Using Debian 9.1, default GUI.
But maybe you're right, the `systemd-inhibit` output will show for sure anyway.
deadbang

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Power Button Enabled To Do Shutdown?

#12 Post by debiman »

^ 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
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Power Button Enabled To Do Shutdown?

#13 Post by GarryRicketson »

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
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Power Button Enabled To Do Shutdown?

#14 Post by debiman »

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.

RickyTerzis
Posts: 1
Joined: 2017-09-12 16:10

Re: Power Button Enabled To Do Shutdown?

#15 Post by RickyTerzis »

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.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Power Button Enabled To Do Shutdown?

#16 Post by debiman »

RickyTerzis wrote:As per my knowledge there is little consistency across distributions at the hardware level.
i don't even know what that's supposed to mean.

anyhow, you should take the time to formulate your problem description, then search for it, apply what you found, and when that doesn't help, and only then, start your own thread.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Power Button Enabled To Do Shutdown?

#17 Post by GarryRicketson »

I suppose it may vary depending on hardware, on my Desktop, and also
on some laptops, just "pushing" the power button once, and briefly , 1 short "push", will either do a re-boot or just a "sleep" mode, to completely shutdown,
power off, I need to push and hold the button, almost 5 seconds, then it will completely shut-down.
On any remote system, obviously ssh is the only option, but even on a machine
that I have access to, ssh is a good option,... I have had computers that had a damaged switch, the button simply would not work, and no keyboard, ssh is a good option, or simply "pull the plug", not a good method and can cause damage.

shinobi
Posts: 14
Joined: 2017-08-17 00:21

Re: Power Button Enabled To Do Shutdown?

#18 Post by shinobi »

Right, I found the same behavior, even if I disable suspend in GNOME settings or Tweak Tool or whatever, even from the command-line... nothing actually works correctly. As you found, the power button invokes suspend. What is really frustrating is Windows OS has consistently supported hardware power management, i.e. Power button control for over a decade. And Red Hat OS (RHEL and CentOS) has trapped Ctrl-Alt-Del to invoke Shutdown as well. But the various Linux distributions can't seem to do anything consistently.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Power Button Enabled To Do Shutdown?

#19 Post by debiman »

shinobi wrote:What is really frustrating is Windows OS has consistently supported hardware power management, i.e. Power button control for over a decade. And Red Hat OS (RHEL and CentOS) has trapped Ctrl-Alt-Del to invoke Shutdown as well. But the various Linux distributions can't seem to do anything consistently.
another "everything-is-better-on-windows" comment ...
makes me wonder why they use linux at all, if it's so frustrating.
to me, using windows is very, very frustrating (on the rare occasions i'm forced to use it - surely not at home).

but, i will agree on a general note: "the various Linux distributions" are indeed very diverse. some would consider that a feature, not a bug.

Post Reply