Changes

Jump to: navigation, search
/* Configure power button event handling */
test* 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: fitlet2CPU: Intel(R) Atom(TM) Processor E3950BIOS: 09/17/2018 American Megatrends Inc. FLT2.0.46.01.00OS: Debian Buster (testing)Kernel: 4.16.0-2-amd64ISO: debian-buster-DI-alpha3-amd64-netinst.iso</pre> == fitlet2: required BIOS settings ==* Press [Delete] button after power-on to enter BIOS settings* Set BIOS -> Main -> OS selection to [Linux] == Configure power button event handling ==* Login as root user (root password required):<pre>$ su -Password:</pre> * Ignore power button events handling by systemd, then reboot:<pre>$ sed -i s/".*HandlePowerKey.*"/"HandlePowerKey=ignore"/ /etc/systemd/logind.conf$ reboot</pre> * Install ACPI related software:<pre>$ apt install acpi-support-base acpid</pre> * Verify acpi events are visible in the system, run acpi_listen command and press power button 2-3 times:<pre>$ acpi_listenbutton/power PBTN 00000080 00000000button/power LNXPWRBN:00 00000080 00000007button/power PBTN 00000080 00000000button/power LNXPWRBN:00 00000080 00000008</pre>NOTE #1: current power button handler is /etc/acpi/powerbtn-acpi-support.sh, but it does not work for some reason NOTE #2: there are 2 events PBTN and LNXPWRBN, we need to handle only one of them, for example PBTN* Create custom power button event rule:<pre>$ cat > /etc/acpi/events/powerbtn-custom-rule << EOFevent=power (PBTN)action=/etc/acpi/powerbtn-custom-handler.shEOF</pre> * Create custom power button event handler and make it executable:<pre>$ cat > /etc/acpi/powerbtn-custom-handler.sh << EOF#!/bin/shecho "Hello from PBTN!" > /dev/tty1EOF $ chmod +x /etc/acpi/powerbtn-custom-handler.sh</pre> * Restart acpid service to activate the new functionality:<pre>$ service acpid restart</pre> * Press power button shortly, you should see "Hello from PBTN!" on the main console
425
edits