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

- name: Install Hyprland emptty session entry
  tags: [packages, services, emptty, hyprland]
  ansible.builtin.template:
    src: Hyprland.desktop.j2
    dest: /etc/emptty/wayland-sessions/Hyprland.desktop
    owner: root
    group: root
    mode: "0644"
  when: "'hyprland' in (desktop_sessions_enabled | default([]))"

- name: Copy Hyprland desktop dotfiles
  tags: [dotfiles, dotfiles:desktop, hyprland]
  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_hyprland_dotfiles | default([]) }}"
  loop_control:
    label: "{{ item.dest }}"
  when: "'hyprland' in (desktop_sessions_enabled | default([]))"
