- include_role:
    name: per_user

- name: Create directories
  file:
    name: "{{ account_homedir.stdout }}/{{ item }}"
    state: directory
    mode: 0700
    owner: "{{ account_name.stdout }}"
    group: "{{ group_name.stdout }}"
  loop:
    - ".config/sway"
    - ".config/sway/config.d"
    - ".config/xdg-desktop-portal-wlr"
    - ".config/mako"
    - ".config/wlogout"
    - .config/gtk-3.0

- name: Copy files
  copy:
    src: "files/{{ item.src }}"
    dest: "{{ account_homedir.stdout }}/{{ item.dest }}"
    mode: 0600
    owner: "{{ account_name.stdout }}"
    group: "{{ group_name.stdout }}"
  loop:
    - src: config
      dest: .config/sway/config
    - src: bliss.jpg
      dest: .config/sway/bliss.jpg
    - src: spaceglenda300.jpg
      dest: .config/sway/spaceglenda300.jpg
    - src: xdg-desktop-portal-wlr-config
      dest: .config/xdg-desktop-portal-wlr/config
    - src: electron-flags.conf
      dest: .config/electron-flags.conf
    - src: mako_config
      dest: .config/mako/config
    - src: settings.ini
      dest: .config/gtk-3.0/settings.ini

- name: Configure dotfiles (conf directory)
  copy:
    src: "files/sway_config_files/{{ item }}.conf"
    dest: "{{ account_homedir.stdout }}/.config/sway/config.d/{{ item }}.conf"
    mode: 0600
    owner: "{{ account_name.stdout }}"
    group: "{{ group_name.stdout }}"
  loop: "{{ sway_conf_files|default([]) + default_sway_conf_files }}"

- import_tasks: tasks/peruser_freebsd.yaml
  when: 'os_flavor == "freebsd"'

- import_tasks: tasks/peruser_linux.yaml
  when: 'os_flavor == "linux"'
