---
- name: seat | Start elogind
  when: seat_manager == 'elogind'
  block:
    - name: seat | Install elogind and polkit-elogind
      community.general.apk:
        name: elogind, polkit-elogind
        state: present

    # Some acpi functions might not work if elogind is started on
    # runlevel 'default'
    - name: seat | Start elogind service on runlevel 'default'
      service:
        name: elogind
        runlevel: default
        enabled: true
        state: started

- name: seat | Start seatd
  when: seat_manager == 'seatd'
  block:
    - name: seat | Install seatd
      community.general.apk:
        name: seatd
        state: present

    - name: seat | Start seatd service on runlevel 'default'
      service:
        name: seatd
        runlevel: default
        enabled: true
        state: started

- name: seat | Install stuff when elogind doesn't exist
  when: seat_manager != 'elogind'
  block:
    - name: seat | Install pam-rundir
      community.general.apk:
        name: pam-rundir
        state: present

    - name: seat | Install polkit
      community.general.apk:
        name: polkit
        state: present
      when: use_polkit
