---
# These archives will never be changed, so use checksum
- name: Download and install cute sound themes
  hosts: all
  tasks:
    - name: Create sound theme directory
      file:
        path: ~/.local/share/sounds
        state: directory
        mode: 0755

    - name: Download kayo sound theme archive
      get_url:
        url: https://oss-ch.info/data/kayo-thema.tar.gz
        dest: /tmp/kayo-thema.tar.gz
        mode: 0644
        checksum: sha256:cbcd1c90c253cb7cf84a04383cb29a1ab8bb5553cbe6c374b6ee1d0e3b35c1f4

    - name: Download sakura sound theme archive
      get_url:
        url: https://oss-ch.info/data/sakura-thema.tar.gz
        dest: /tmp/sakura-thema.tar.gz
        mode: 0644
        checksum: sha256:2cc410c1a692c8a11a6308799392c14e8509c627ead14e24a6052796101f0ccb

    - name: Download libreoffice-writer sound theme archive
      get_url:
        url: https://oss-ch.info/lbr/lbr_ubuntu_writer.tgz
        dest: /tmp/lbr_ubuntu_writer.tgz
        mode: 0644
        checksum: sha256:fbfec3edfad3b60891fcac956f1beef2e9ce2b74f7e27796e611c7a19ae55cfc

    - name: Download libreoffice-impress sound theme archive
      get_url:
        url: https://oss-ch.info/lbr/lbr_ubuntu_impress.tgz
        dest: /tmp/lbr_ubuntu_impress.tgz
        mode: 0644
        checksum: sha256:29cd56b1190bf3073fca742bd40ffe33df7c4e4d5af1a19fd21d1d76d3bba681

    - name: Download libreoffice-calc sound theme archive
      get_url:
        url: https://oss-ch.info/lbr/lbr_ubuntu_calc.tgz
        dest: /tmp/lbr_ubuntu_calc.tgz
        mode: 0644
        checksum: sha256:4eb40e988f6cf3ebc4ef31bde8518190257bcb9e45f6cd125f0915788f5001f1

    - name: Download libreoffice-draw sound theme archive
      get_url:
        url: https://oss-ch.info/lbr/lbr_ubuntu_draw.tgz
        dest: /tmp/lbr_ubuntu_draw.tgz
        mode: 0644
        checksum: sha256:bc8f9398d653dfe84a6561ed783ab1e4b53c03c2652f747cf9c32412292fb307

    - name: Install sakura/kayo sound theme
      command: 'tar -xzf /tmp/{{ item }}-thema.tar.gz'
      args:
        chdir: ~/.local/share/sounds
        creates: '~/.local/share/sounds/{{ item }}/index.theme'
      loop:
        - kayo
        - sakura

    - name: Extract Libreoffice sound themes to /tmp
      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: Install Libreoffice sound themes
      copy:
        src: /tmp/usr/share/sounds/LBR_{{ item | capitalize }}
        dest: ~/.local/share/sounds/
        directory_mode: 0755
        mode: 0644
      loop:
        - writer
        - impress
        - draw
        - calc
