---
# elogind also handles acpi events
- block:
    - name: acpi | Do not run acpid service
      service:
        name: acpid
        enabled: no
        state: stopped

    - block:
        - name: acpi | Create custom config directory for logind.conf
          file:
            path: /etc/elogind/logind.conf.d
            state: directory
            mode: 0755
            owner: root
            group: root

        - name: acpi | Copy logind.conf
          copy:
            src: logind.conf
            dest: /etc/elogind/logind.conf.d/custom.conf
            mode: 0644
            owner: root
            group: root
      tags: laptop
  when: seat_manager == 'elogind'

# Busybox's acpid
- block:
    - block:
        - name: acpi | Create directory for Lid Close event
          file:
            path: /etc/acpi/LID
            state: directory
            mode: 0755
            owner: root
            group: root

        - name: acpi | Copy event handler for Lid Close
          copy:
            src: acpid_lid_close
            dest: /etc/acpi/LID/00000080
            mode: 0755
            owner: root
            group: root
      tags: laptop

    - name: acpi | Enable acpid service on runlevel 'default'
      service:
        name: acpid
        runlevel: default
        enabled: yes
        state: started
  when: seat_manager != 'elogind'
