[systemd-devel] diverting HandlePowerKey

Lennart Poettering lennart at poettering.net
Thu Aug 16 10:36:21 PDT 2012


On Thu, 16.08.12 16:27, Robin Becker (robin at reportlab.com) wrote:

> However, I'm a bit lost on what's the correct way for a user program
> to signal that it wants to shut down etc. Slim appears to be running
> polkit/consolekit so presumably I can use that, but is there a
> preferred systemd approach? Clearly just doing sudo halt etc etc is
> the wrong approach.

Invoke the PowerOff() call on the org.freedesktop.login1.Manager
interface of the /org/freedesktop/login1 object on the
org.freedesktop.login1 service. Which is basically what "systemctl
poweroff" does.

> >>Is there a way to divert HandlePowerKey to a script of my choosing?
> >
> >No, there currently isn't. Eventually might add something that would
> >allow people to reconfigure what happens when people press the
> >power/sleep keys. But I am not sure we'll allow specification of
> >arbitrary scripts for that.
>
> sounds a bit strict, but perhaps I'm a bit of an anarchist. I
> definitely think you should allow control over whether suspend or
> hibernate or shutdown gets done for at least the lid button.

Well, we try to cover the big usecases for this and do not intend to
provide a solution for everything thinkable. I mean, we make sure that
other components of the OS can get these keypresses too, so that people
have full flexibility in what they want to happen if the stuff in
systemd itself does not cover their specific usecase fully.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list