Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I set the power button (on my computer case, not keyboard) to power off the system with systemd (without acpid)?

share|improve this question

systemd can handle this. I think this is what you need:

Open the /etc/systemd/logind.conf (manual):

  • HandlePowerKey: action on power key is pressed;
  • HandleSuspendKey: action on suspend key is pressed.
  • HandleHibernateKey: action on hibernate key is pressed.
  • HandleLidSwitch: action when the lid is closed.

The action can be one of ignore, poweroff, reboot, halt, suspend, hibernate or kexec.

If no configuration, default values used:

  • HandlePowerKey=poweroff
  • HandleSuspendKey=suspend
  • HandleHibernateKey=hibernate
  • HandleLidSwitch=suspend
share|improve this answer
I think this parameters related with buttons on keyboard ("Power", "Sleep", etc.), isn't it? (Unfortunately, I can't check it now.) – Corvus Oct 13 '12 at 10:16
I'm frustrated. =) What's the difference? The power button is the button, by which you power on the PC. Anyway, long press of this key would halt PC regardless of OS settings. – m0nhawk Oct 13 '12 at 10:22
I set all Handle*Key to ignore, because button 'Power', 'Sleep' and 'Wake' are placed near arrows and Enter on my keyboard. I can press it by accident. I need to handle power button on my computer case. – Corvus Oct 13 '12 at 10:27
Can you provide more info about keys? For example model of keyboard or PC, because I stop understanding of what keys you are talking. – m0nhawk Oct 13 '12 at 10:34
Look at these photos: link, link – Corvus Oct 13 '12 at 10:42

I don't see it's related with systemd, but on my system that has acpid installed, it respond to power button press automatically.

Can be defined through /etc/acpi/handler.sh (On Arch Linux)

share|improve this answer
It's related with systemd because systemd replace acpid's functionality. I can use both systemd and acpid anyway, but I want to use only the first one. I have edited my question. – Corvus Oct 13 '12 at 9:17

I believe you need to configure that in your BIOS (if it supports it). I don't see how the power button on the case has anything to do with your OS, where a power button on your keyboard does interact with the OS since the OS loads drivers for the keyboard.

share|improve this answer
I have seen as pressing power button on case cause correct poweroff of MS Windows. So, generally speaking, OS can handle power button on case. – Corvus Oct 13 '12 at 10:41
en.wikipedia.org/wiki/Acpi – Dave Apr 1 '15 at 23:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.