---
- block:
    - name: seat | Install elogind and polkit-elogind
      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: yes
        state: started
  when: seat_manager == 'elogind'

- block:
    - name: seat | Install pam-rundir
      apk:
        name: pam-rundir
        state: present

    - name: seat | Add pam_rundir.so to /etc/pam.d/base-session
      pamd:
        name: base-session
        type: -session
        control: optional
        module_path: pam_elogind.so
        new_type: -session
        new_control: optional
        new_module_path: pam_rundir.so
        state: after

    - name: seat | Install polkit
      apk:
        name: polkit
        state: present
      when: use_polkit
  when: seat_manager != 'elogind'

- block:
    - name: seat | Install seatd
      apk:
        name: seatd
        state: present

    - name: seat | Start seatd service on runlevel 'default'
      service:
        name: seatd
        runlevel: default
        enabled: yes
        state: started
  when: seat_manager == 'seatd'
