---

- name: i3 config directory
  file:
    path: ~/.config/i3
    state: directory

- name: i3 null config
  template:
    src: i3/i3.null.config.j2
    dest: ~/.config/i3/null.config

- name: i3 config
  template:
    src: i3/i3.config.j2
    dest: ~/.config/i3/config
  notify: i3 reload

- name: check i3 config
  command: i3 -c ~/.config/i3/config -C
  changed_when: false

- name: i3blocks config directory
  file:
    path: ~/.config/i3blocks
    state: directory
  notify: i3 reload

- name: i3blocks config
  template:
    src: i3/i3blocks.config.j2
    dest: ~/.config/i3blocks/config
  notify: i3 reload

- name: i3wm graphical-session service
  template:
    src: i3/i3wm.service.j2
    dest: ~/.config/systemd/user/i3wm.service
  notify: systemd daemon-reload

- name: flush handlers
  meta: flush_handlers

- name: i3wm graphical-session service enabled
  systemd:
    name: i3wm.service
    enabled: true
    scope: user
