---
- name: Install desktop and educational packages
  ansible.builtin.apt:
    name: "{{ kde_desktop_pkg }}"

- name: Add backports {{ ansible_distribution_release }}
  ansible.builtin.apt_repository:
    repo: deb http://deb.debian.org/debian/ {{ ansible_distribution_release }}-backports main non-free-firmware
    state: present
    update_cache: true

- name: Install extra packages from backports
  ansible.builtin.apt:
    name:
      - filius
      - kicad
      - kicad-doc-de
      - libreoffice
      - libreoffice-l10n-de
      - libreoffice-qt5
    state: latest # noqa package-latest
    autoremove: true
    default_release: "{{ ansible_distribution_release }}-backports"


- name: Create akonadi config dir
  ansible.builtin.file:
    path: /etc/xdg/akonadi/
    state: directory
    mode: '0755'

- name: Use sqlite in akonadi
  ansible.builtin.blockinfile:
    path: /etc/xdg/akonadi/akonadiserverrc
    create: true
    mode: '0644'
    block: |
      [%General]
      Driver=QSQLITE3

## Akonadi complains if not set:
- name: Add home dirs to apparmor
  ansible.builtin.lineinfile:
    dest: /etc/apparmor.d/tunables/home.d/ubuntu
    line: >-
      @{HOMEDIRS}+=/srv/samba/schools/default-school/teachers/
      /srv/samba/schools/default-school/students/*/
      /srv/samba/schools/default-school/examusers/


- name: Tune SDDM login
  ansible.builtin.blockinfile:
    path: /etc/sddm.conf
    create: true
    mode: '0644'
    block: |
      [Users]
      MaximumUid=999
      RememberLastUser=false
      RememberLastSession=false

- name: Deploy dolphin script
  ansible.builtin.copy:
    src: lmn-fix-dolphin.sh
    dest: /usr/local/bin/
    mode: '0755'

- name: Default KDE filepicker
  ansible.builtin.lineinfile:
    path: /etc/environment.d/90lmn-filepicker.conf
    create: true
    mode: '0644'
    line: GTK_USE_PORTAL=1
