system/roles/acpi/tasks/main.yaml
Marty Oehme 421df69cc9
feat(acpi): Add custom LID event handling
We disable the default ACPI handler script logic for LID events.
We _only_ disable that in the script - the default handler script will
still fire for LID events, just not do anything in its routine. That is
so that in the future it is easy to rectify with any upstream changes.
If, over time we add more custom event and action chain to our ACPI
settings, we can think about spinning out all event types into our own
rules and completely disabling the deafult handler script.

Our custom LID action only fires for LID open close events, and only
logs that the lid has been opened for open events. For close events, it
adds one extra step before suspending: Checking if any DP screens are
connected - and inhibiting suspend then. That way we still automatically
suspend when closing the screen lid if we are in portable mode (no
external screens connected) but do nothing if they are.
2025-03-13 11:24:17 +01:00

41 lines
946 B
YAML

---
# ACPI comes preinstalled on void systems
- name: Remove lid handling from default handler
ansible.builtin.copy:
src: default-handler.sh
dest: /etc/acpi/handler.sh
mode: 0755
force: true
notify: acpi-rule-reload
- name: Ensure acpi config directories exist
ansible.builtin.file:
dest: "/etc/acpi/{{ item }}"
state: directory
mode: 0755
loop:
- events
- actions
- name: Add separate lid button event rule
ansible.builtin.copy:
src: events/button-lid
dest: /etc/acpi/events/button-lid
mode: 0644
force: true
notify: acpi-rule-reload
- name: Add corresponding lid handler action
ansible.builtin.copy:
src: actions/button-lid.sh
dest: /etc/acpi/actions/button-lid.sh
mode: 0755
force: true
notify: acpi-rule-reload
- name: Activate acpid service
ansible.builtin.file:
src: "/etc/sv/acpid"
dest: "/etc/runit/runsvdir/default/acpid"
state: link