---
- name: mpd | Create config directories
  file:
    path: '{{ xdg_dir.config_home }}/{{ item }}'
    state: directory
    mode: '755'
  loop:
    - '{{ music_daemon }}'
    - ncmpcpp
    - mpDris2

# Or else mpd will fail to start
- name: mpd | Create playlists directory in ~/.local/share/{{ music_daemon }}
  file:
    path: '{{ xdg_dir.data_home }}/{{ music_daemon }}/playlists'
    state: directory
    mode: '755'

- name: mpd | Copy mpd config
  template:
    src: mpd/mpd.j2
    dest: '{{ xdg_dir.config_home }}/mpd/mpd.conf'
    mode: '644'
  when: music_daemon == 'mpd'

- name: mpd | Copy mopidy config
  template:
    src: mopidy/mopidy.j2
    dest: '{{ xdg_dir.config_home }}/mopidy/mopidy.conf'
    mode: '644'
  when: music_daemon == 'mopidy'

- name: mpd | Copy mpDris2 config
  template:
    src: mpDris2/mpDris2.j2
    dest: '{{ xdg_dir.config_home }}/mpDris2/mpDris2.conf'
    mode: '644'

- name: mpd | Copy ncmpcpp config
  template:
    src: ncmpcpp/config.j2
    dest: '{{ xdg_dir.config_home }}/ncmpcpp/config'
    mode: '644'
