11

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

10

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
  • I think this parameters related with buttons on keyboard ("Power", "Sleep", etc.), isn't it? (Unfortunately, I can't check it now.) – user14284 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. – user14284 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 – user14284 Oct 13 '12 at 10:42
1

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)

  • 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. – user14284 Oct 13 '12 at 9:17
-1

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.

  • 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. – user14284 Oct 13 '12 at 10:41
  • en.wikipedia.org/wiki/Acpi – Dave Apr 1 '15 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy