acpi: add normal acpid variant

Busybox's acpid doesn't support netlink
This commit is contained in:
Hoang Nguyen 2022-08-07 16:33:21 +07:00
parent 8d151d727f
commit eababf0fa2
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
3 changed files with 50 additions and 1 deletions

View File

@ -19,6 +19,10 @@ kernel_parameters:
# 'seatd' or 'elogind'
seat_manager: seatd
# acpid implementation to use when elogind is not present
# 'busybox' or 'acpid'
acpid_daemon: busybox
# busybox's mdev, skarnet's mdevd or eudev's udev
device_manager: mdevd

View File

@ -0,0 +1,30 @@
#!/bin/sh
PATH="/usr/share/acpid:$PATH"
alias log='logger -t acpid'
# <dev-class>:<dev-name>:<notif-value>:<sup-value>
case "$1:$2:$3:$4" in
button/power:PWRF:* | button/power:PBTN:*)
log 'Power button pressed'
poweroff
;;
button/sleep:SLPB:*)
log 'Sleep button pressed'
# Suspend to RAM.
zzz
;;
button/lid:*:close:*)
log 'Lid closed'
# Suspend to RAM if AC adapter is not connected.
[ "$(power-supply -d adapter -s)" = "offline" ] && zzz
;;
ac_adapter:*:*:*0)
log 'AC adapter unplugged'
# Suspend to RAM if notebook's lid is closed.
lid-state -c && zzz
;;
esac
exit 0

View File

@ -26,8 +26,22 @@
tags: laptop
when: seat_manager == 'elogind'
# Busybox's acpid
- block:
- block:
- name: acpi | Install acpid and acpi-utils
apk:
name: acpid, acpi-utils
state: present
- name: acpi | Copy acpid event handler script
copy:
src: handler.sh
dest: /etc/acpi/handler.sh
mode: 0755
owner: root
group: root
when: acpid_daemon == 'acpid'
- block:
- name: acpi | Create directory for Lid Close event
file:
@ -45,6 +59,7 @@
owner: root
group: root
tags: laptop
when: acpid_daemon == 'busybox'
- name: acpi | Enable acpid service on runlevel 'default'
service: