---

- name: desktop app service
  template:
    src: desktop-apps/desktop-app.service.j2
    dest: ~/.config/systemd/user/desktop-app@.service
    mode: 0755
  notify: systemd daemon-reload

- name: enable autostart desktop apps
  systemd:
    name: desktop-app@{{ app.command }}.service
    enabled: true
    scope: user
  loop: "{{ home_autostart_desktop_apps | json_query(\"[?enabled]\") }}"
  loop_control:
    label: "{{ app.name }}"
    loop_var: app

- name: disable autostart desktop apps
  systemd:
    name: desktop-app@{{ app.command }}.service
    enabled: false
    scope: user
  loop: "{{ home_autostart_desktop_apps | json_query(\"[?!enabled]\") }}"
  loop_control:
    label: "{{ app.name }}"
    loop_var: app
  failed_when: false
