Changes

Jump to: navigation, search
/* Configure power button event handling */
* This application note provides an example of how to capture a power button click event on Linux.
* It has been tested with the below setup:
<pre>
Device: fitlet2
CPU: Intel(R) Atom(TM) Processor E3950
BIOS: 09/17/2018 American Megatrends Inc. FLT2.0.46.01.00
OS: Debian Buster (testing)
Kernel: 4.16.0-2-amd64
ISO: debian-buster-DI-alpha3-amd64-netinst.iso
</pre>
Device: == fitlet2 CPU: Intel(R) Atom(TM) Processor E3950 required BIOS: 09/17/2018 American Megatrends Inc. FLT2.0.46.01.00settings == OS: Debian Buster (development) Kernel: 4.13.0* Press [Delete] button after power-1-amd64 on to enter BIOS settings1. * Set BIOS -> Main -> OS selection to [Linux]
2. Ignore == Configure power button event handling provided by systemd, don't forget to reboot==* Login as root user (root password required): <pre>$ sudo sed su -i s/".*HandlePowerKey.*"/"HandlePowerKey=ignore"/ /etc/systemd/logind.conf $ sudo rebootPassword:</pre>
3. Install ACPI related software if not installed yet* Ignore power button events handling by systemd, then reboot: <pre>$ sudo apt install acpised -support-base acpidi s/".*HandlePowerKey.*"/"HandlePowerKey=ignore"/ /etc/systemd/logind.conf$ reboot</pre>
$ service acpid status ● acpid.service - * Install ACPI event daemon Loadedrelated software: loaded (/lib/systemd/system/acpid.service; disabled; vendor preset: enabled) Active: active (running) since Tue 2018<pre>$ apt install acpi-10support-16 05:56:43 EDT; 1s ago Main PID: 1754 (base acpid) Tasks: 1 (limit: 4915) CGroup: </system.slice/acpid.service └─1754 /usr/sbin/acpidpre>
Oct 16 05:56:43 x86* Verify acpi events are visible in the system, run acpi_listen command and press power button 2-atp-master systemd[1]3 times: Started ACPI event daemon. Oct 16 05<pre>$ acpi_listenbutton/power PBTN 00000080 00000000button/power LNXPWRBN:5600 00000080 00000007button/power PBTN 00000080 00000000button/power LNXPWRBN:43 x86-atp-master acpid[1754]: starting up with netlink and the input layer00 00000080 00000008 Oct 16 05:56:43 x86-atp-master acpid[1754]: </pre>NOTE #1 rule loaded Oct 16 05:56:43 x86current power button handler is /etc/acpi/powerbtn-atpacpi-master acpid[1754]: waiting support.sh, but it does not work for events: event logging is offsome reason
4. Verify acpi events NOTE #2: there are visible in the system, run acpi_listen tool 2 events PBTN and press LNXPWRBN, we need to handle only one of them, for example PBTN* Create custom power button 2-3 timesevent rule: $ acpi_listen<pre> button$ cat > /etc/acpi/events/powerbtn-custom-rule << EOFevent=power (PBTN 00000080 00000000) buttonaction=/power LNXPWRBN:00 00000080 00000007 buttonetc/power PBTN 00000080 00000000acpi/powerbtn-custom-handler.sh buttonEOF</power LNXPWRBN:00 00000080 00000008pre>
5. Edit * Create custom power button event handler and make it executable:<pre>$ cat > /etc/acpi/events/powerbtn-acpicustom-support:handler.sh << EOF#!/bin/shecho event=power ("Hello from PBTN) 00000080 action=!" > /etcdev/acpi/powerbtn-acpi-support-new.shtty1EOF
6. Create your custom script named $ chmod +x /etc/acpi/powerbtn-acpicustom-support-newhandler.sh: #!</bin/sh echo "Hello from PBTN!" pre> /dev/tty1
7. Make it executable* Restart acpid service to activate the new functionality:<pre> $ chmod +x service acpid restart</etc/acpi/powerbtn-acpi-support-new.shpre>
8. Restart acpid service to activate the new functionality $ service acpid restart 9. * Press power button shortly, you should see: "Hello from PBTN!" on tty1the main console
425
edits