2

I want to execute a custom script upon pressing the build in power button. I am aware that I can disable the power button by editing: /etc/systemd/logind.conf. Is there any way to have it execute a script instead?

Oll
  • 191
  • 1
  • 8

1 Answers1

2

Turn off the default behaviour of the power button, make sure /etc/systemd/logind.conf contains:

HandlePowerKey=ignore

Thanks to a hint from Raspberry Pi forums.

You can edit the .config/wayfire.ini in your home folder.

Look for the lines called:

binding_power = KEY_POWER

command_power = pwrkey

leave binding_power the same, edit command_power to: command_power = exec /path/to/bash/script.sh

Important: run sudo chmod +x /path/to/bash/script.sh, otherwise it will not execute the bash script upon button press.

Reboot to set the new configuration.

Edit 1: Important. If there is no wayfire.ini file in your .config folder; Enable Wayfire in raspi-config > 6 Advanced Options > A6 Wayland > W2 Wayfire OR run sudo raspi-config nonint do_wayland W2 Then Reboot

Oll
  • 191
  • 1
  • 8