---
- name: Ensure i3 config directories exist
  tags: [dotfiles, dotfiles:desktop, i3]
  ansible.builtin.file:
    path: "{{ item }}"
    state: directory
    owner: "{{ username }}"
    group: "{{ user_group }}"
    mode: "0755"
  loop:
    - "{{ user_home }}/.config/i3"
    - "{{ user_home }}/.config/i3blocks"
  when: "'i3' in (desktop_sessions_enabled | default([]))"

- name: Install allowed emptty X11 sessions
  tags: [packages, services, emptty, i3]
  ansible.builtin.copy:
    src: i3.desktop
    dest: /etc/emptty/xsessions/i3.desktop
    owner: root
    group: root
    mode: "0644"
  when: "'i3' in (desktop_sessions_enabled | default([]))"

- name: Copy i3 desktop dotfiles
  tags: [dotfiles, dotfiles:desktop, i3]
  ansible.builtin.copy:
    src: "{{ playbook_dir }}/../dotfiles/desktop/{{ item.src }}"
    dest: "{{ user_home }}/{{ item.dest }}"
    owner: "{{ username }}"
    group: "{{ user_group }}"
    mode: "{{ item.mode }}"
  loop: "{{ desktop_i3_dotfiles | default([]) }}"
  loop_control:
    label: "{{ item.dest }}"
  when: "'i3' in (desktop_sessions_enabled | default([]))"
