---
{%- from "nextcloud_desktop/map.jinja" import nextcloud_desktop with context %}

nextcloud-desktop-appimage:
  file.managed:
    - name: {{ nextcloud_desktop.dest_path }}-{{ nextcloud_desktop.version }}
    - source: {{ nextcloud_desktop.url }}/Nextcloud-{{ nextcloud_desktop.version }}-x86_64.AppImage
    - skip_verify: true
    - user: root
    - group: root
    - mode: "0755"
    - if_missing: {{ nextcloud_desktop.dest_path }}-{{ nextcloud_desktop.version }}

nextcloud-desktop-install-link:
  file.symlink:
    - name: {{ nextcloud_desktop.dest_path }}
    - target: {{ nextcloud_desktop.dest_path }}-{{ nextcloud_desktop.version }}
    - force: true
    - watch:
      - file: nextcloud-desktop-appimage

nextcloud-desktop-icon:
  file.managed:
    - name: /usr/share/icons/nextcloud.png
    - source: salt://nextcloud_desktop/nextcloud.png
    - user: root
    - group: root
    - mode: "0644"

nextcloud-desktop-icon-entry:
  file.managed:
    - name: /usr/share/applications/nextcloud.desktop
    - source: salt://nextcloud_desktop/nextcloud.desktop
    - user: root
    - group: root
    - mode: "0644"