---
- name: Install polybar
  aur:
    name:
      - siji-git
      - polybar
    skip_installed: yes

- name: Create polybar conf dir
  file:
    path: ~/.config/polybar
    state: directory

- name: Add pkg check script
  copy:
    src: pkg.sh
    dest: ~/.config/polybar/
    mode: 0755
  notify: restart polybar

- name: Sync bars
  synchronize:
    src: files/bars
    dest: ~/.config/polybar/
  notify: restart polybar

- name: Sync modules
  synchronize:
    src: files/modules
    dest: ~/.config/polybar/
  notify: restart polybar

- name: Test if node specific template exists for launch.sh
  stat:
    path: "{{ role_path }}/templates/by_host/{{ ansible_hostname }}/launch.j2"
  register: launch_file

- name: Template launch file
  template:
    src: launch.j2
    dest: ~/.config/polybar/launch.sh
    mode: 0755
    backup: yes
  notify: restart polybar

- name: Template config file
  copy:
    src: config
    dest: ~/.config/polybar/
    backup: yes
  notify: restart polybar
