0

I would like to find out why my power button press isn't handled correctly. I've set power manager in XFCE4 to 'ask' me, but all that happens is I'm getting logged out of my session. I have contacted the devs because of this already as well and the assumption by now is, that some XFCE4-unrelated program is blocking processing of the power button keypress.

I'm running Devuan on a Thinkpad. Have already tried disabling tlp and acpi and maybe some other services that I thought might be interfering (including elogind, Devuan's chosen alternative to logind that does similar things). Login manager is SLIM.

Anyways, that's the basic info, my question is if there is any way to track what processes are trying to handle the power button press. System logs weren't very informative, at least I didn't see anything of relevance in /var/log/syslog and I think I also took a look at /var/log/dmesg/dmesg but don't recall finding anything of relevance.

The way I imagine it with my mediocre Linux knowledge is that the power button raises an interrupt via the kernel, and certain programs have registered handlers for this interrupt -- modulo some translation of that interrupt to higher layers. So... I guess it boils down to two questions:

  1. shouldn't there be some kind of handler lists for each relevant layer where I could look up which programs are trying to handle my power button press?
  2. shouldn't there be some kind of way to see how the power button press is represented in each layer?

I guess if I can get that information, then debugging the power button press on my laptop should be no issue at all.

Note: I guess this SE post is somewhat related, but I am more interested in the handler registration/handler side of this. To me it seems like the issue is taking place in the application layer.

1 Answer 1

1

In the x86 PC architecture, a shorter-than-4-seconds press of the power button is typically delivered to the operating system kernel as an ACPI event. Turning it into a regular keyboard event would require translation of some sort.

A "power key" keyboard event usually refers to a specific key on the keyboard of some non-PC hardware architectures (such as Sun SPARC architecture used to have) or extended PC keyboards (with more than the standard 104/105 keys).

The power button is fundamentally different from a key press, since the default meaning is along the lines of "someone with physical access to the hardware wants the system to shut down". Whoever pressed the power button is likely to be in the position to start physically pulling plugs and removing batteries if they don't get what they want, so an immediate reaction without further questions is generally an appropriate default.

With most modern PC hardware, holding down the power button for more than 4 seconds is expected to force a hard power-off anyway, so any confirmation or authentication you might add to the process can usually be trivially bypassed.

According to elogind's Github page, it does monitor power button events:

Elogind does monitor power button and the lid switch, like systemd, but instead of doing RPC to systemd to suspend, poweroff, or restart the machine, elogind just does this directly.

You don't seem to be the only one with issues regarding the power button: in elogind Github, there is an open issue with elogind version 255.17 in combination with KDE on Slackware, where pressing the power button causes an immediate shutdown instead of the dialog expected by the person posting the issue.

However, in the above-mentioned issue, the poster of the issue has configured elogind to ignore any power key events, and the shutdown is apparently triggered by acpid and its event handler script /etc/acpi/acpi_handler.sh.

acpid is typically strictly a system-level service, that does not participate in user sessions. Triggering a dialog from it is likely to be difficult. elogind supports D-Bus, so it would have an easier way to signal a system-wide event that could cause a dialog to pop up in user session(s).

On the other hand, elogind seems to have some special udev rules that suggest a thinkpad_acpi kernel module might be responsible for turning the press of a Thinkpad power button into a keyboard event. Do you have this module loaded (or built-in)?

1
  • Thank you for your reply, really helpful pointers there :) Yes, I do have thinkpad_acpi loaded . Are you implying that module might be causing the issue? It's also not loaded on my Desktop (obviously I guess), where the power button works. I don't have anything about thinkpad or acpi in /etc/elogind (grepped through there...) though... Commented Nov 18 at 13:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.