---
- name: xdg-desktop-portal-wlr | Create config directory
  file:
    path: '{{ xdg_dir.config_home }}/xdg-desktop-portal-wlr'
    state: directory
    mode: '755'

- name: xdg-desktop-portal-wlr | Copy config
  template:
    src: xdg-desktop-portal-wlr/config.j2
    dest: '{{ xdg_dir.config_home }}/xdg-desktop-portal-wlr/config'
    mode: '644'

- name: xdg-desktop-portal | Create portal config directory
  file:
    path: '{{ xdg_dir.config_home }}/xdg-desktop-portal'
    mode: '755'
    state: directory

# Docs: https://github.com/flatpak/xdg-desktop-portal/blob/main/doc/portals-conf.rst
# Portal APIs: https://flatpak.github.io/xdg-desktop-portal/
- name: xdg-desktop-portal | Create portal config for wlr-based compositors
  copy:
    content: |
      [preferred]
      default=gtk
      org.freedesktop.impl.portal.RemoteDesktop=wlr
      org.freedesktop.impl.portal.ScreenCast=wlr
      org.freedesktop.impl.portal.Screenshot=wlr
    dest: '{{ xdg_dir.config_home }}/xdg-desktop-portal/{{ item }}-portals.conf'
    mode: '644'
  loop:
    - sway
    - river
