---
# These archives will never be changed, so use checksum

- name: soundtheme | Create sound theme directory
  file:
    path: '{{ xdg_dir.data_home }}/sounds'
    state: directory
    mode: '755'

- name: soundtheme | Download kayo sound theme archive
  get_url:
    url: https://www.oss-ch.jp/data/kayo-thema.tar.gz
    dest: /tmp/kayo-thema.tar.gz
    mode: '644'
    checksum: sha256:cbcd1c90c253cb7cf84a04383cb29a1ab8bb5553cbe6c374b6ee1d0e3b35c1f4

- name: soundtheme | Download sakura sound theme archive
  get_url:
    url: https://www.oss-ch.jp/data/sakura-thema.tar.gz
    dest: /tmp/sakura-thema.tar.gz
    mode: '644'
    checksum: sha256:2cc410c1a692c8a11a6308799392c14e8509c627ead14e24a6052796101f0ccb

- name: soundtheme | Download libreoffice-writer sound theme archive
  get_url:
    url: https://www.oss-ch.jp/lbr/lbr_ubuntu_writer.tgz
    dest: /tmp/lbr_ubuntu_writer.tgz
    mode: '644'
    checksum: sha256:fbfec3edfad3b60891fcac956f1beef2e9ce2b74f7e27796e611c7a19ae55cfc

- name: soundtheme | Download libreoffice-impress sound theme archive
  get_url:
    url: https://www.oss-ch.jp/lbr/lbr_ubuntu_impress.tgz
    dest: /tmp/lbr_ubuntu_impress.tgz
    mode: '644'
    checksum: sha256:29cd56b1190bf3073fca742bd40ffe33df7c4e4d5af1a19fd21d1d76d3bba681

- name: soundtheme | Download libreoffice-calc sound theme archive
  get_url:
    url: https://www.oss-ch.jp/lbr/lbr_ubuntu_calc.tgz
    dest: /tmp/lbr_ubuntu_calc.tgz
    mode: '644'
    checksum: sha256:4eb40e988f6cf3ebc4ef31bde8518190257bcb9e45f6cd125f0915788f5001f1

- name: soundtheme | Download libreoffice-draw sound theme archive
  get_url:
    url: https://www.oss-ch.jp/lbr/lbr_ubuntu_draw.tgz
    dest: /tmp/lbr_ubuntu_draw.tgz
    mode: '644'
    checksum: sha256:bc8f9398d653dfe84a6561ed783ab1e4b53c03c2652f747cf9c32412292fb307

- name: soundtheme | Install sakura and kayo sound themes # noqa: command-instead-of-module
  command: 'tar -xzf /tmp/{{ item }}-thema.tar.gz'
  args:
    chdir: '{{ xdg_dir.data_home }}/sounds'
    creates: '{{ xdg_dir.data_home }}/sounds/{{ item }}/index.theme'
  loop:
    - kayo
    - sakura

- name: soundtheme | Extract Libreoffice sound themes to /tmp # noqa: command-instead-of-module
  command: 'tar -xzf /tmp/lbr_ubuntu_{{ item }}.tgz'
  args:
    chdir: /tmp
    creates: /tmp/usr/share/sounds/LBR_{{ item | capitalize }}/index.theme
  loop:
    - writer
    - impress
    - draw
    - calc

- name: soundtheme | Install Libreoffice sound themes
  copy:
    src: /tmp/usr/share/sounds/LBR_{{ item | capitalize }}
    dest: '{{ xdg_dir.data_home }}/sounds/'
    directory_mode: '755'
    mode: '644'
  loop:
    - writer
    - impress
    - draw
    - calc
