[systemd-devel] Having systemd shutdown when pressing the power button

Mantas Mikulėnas grawity at gmail.com
Thu Aug 28 06:37:16 PDT 2014


On Thu, Aug 28, 2014 at 4:35 PM, Koen Kooi <koen at dominion.thruhere.net> wrote:
>
>
> Op 28 aug. 2014, om 11:06 heeft Mantas Mikulėnas <grawity at gmail.com> het volgende geschreven:
>
> > On Thu, Aug 28, 2014 at 11:50 AM, Koen Kooi <koen at dominion.thruhere.net> wrote:
> >>
> >> Hi,
> >>
> >> I am working on a system (http://www.acmesystems.it/arietta) where I hooked up the button as a power key:
> >>
> >>        https://github.com/koenkooi/linux/commit/c823e0b046efcfff61e21fa4c89d5d68090ef6de
> >>
> >> Evtest shows it doing the right thing (issuing KEY_POWER) when being pressed, but systemd seems to totally ignore it. I've seen this behaviour in the past and noticed the DE (GNOME2, old but it works) would pick it up and present the dialog. Since this is a headless system I want systemd to handle it instead of the DE (which isn't installed).
> >
> > Yes, systemd-logind handles the key events, unless something inhibits
> > this. For example, GNOME 3 does:
> >
> > $ systemd-inhibit --list
> >     Who: grawity (UID 1000/grawity, PID 945/gnome-settings-)
> >    What: handle-power-key:handle-suspend-key:handle-hibernate-key
> >     Why: GNOME handling keypresses
> >    Mode: block
> >
> >> Every doc or blog post I read says that systemd should already be handling it, but it isn't in my case. I suspect that systemd only handles ACPI powerkey events, but I haven't actually looked at the code.
> >
> > It receives the events via /dev/input, whether ACPI or not. Reading
> > src/login/logind-button.c:155, it checks for either KEY_POWER or
> > KEY_POWER2.
> >
> > Make sure it correctly detects your input device. You should be seeing
> > something like this in the logs:
> >
> > logind[388]: New seat seat0.
> > logind[388]: Watching system buttons on /dev/input/event3 (Power Button)
> > logind[388]: Watching system buttons on /dev/input/event4 (Video Bus)
> > logind[388]: Watching system buttons on /dev/input/event1 (Lid Switch)
> > logind[388]: Watching system buttons on /dev/input/event2 (Sleep Button)
> > logind[388]: New session c1 of user gdm.
> > logind[388]: Lid closed.
>
> So what happens when no one is logged in?

Nothing special; systemd-logind runs regardless of whether any user
sessions are active, and it continues handling the lid/button events
according to configuration.

-- 
Mantas Mikulėnas <grawity at gmail.com>


More information about the systemd-devel mailing list