#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Configure system packages
  block:
  - name: Enable i386 architecture
    lineinfile:
      dest: /var/lib/dpkg/arch
      line: i386
      create: yes
  - name: Add repo keys from keyserver
    apt_key:
      keyserver: 'keyserver.ubuntu.com'
      id: "{{ item }}"
    loop:
      - "3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" # Monodevelop
  - name: Add repo keys by URL
    apt_key:
      url: "{{ item }}"
    loop:
      - "https://packages.riot.im/debian/riot-im-archive-keyring.gpg" # Element
  - name: Add repos
    apt_repository:
      repo: "{{ item }}"
    loop:
      # Monodevelop
      - "deb https://download.mono-project.com/repo/ubuntu vs-bionic main"
      # Element
      - "deb https://packages.riot.im/debian/ default main"
      # First-party PPAs
      - "ppa:phoerious/keepassxc" # KeepassXC
      # Third-party PPAs
      - "ppa:system76-dev/stable"
      - "ppa:drewwalton19216801/dolphin-master-cosmic" # Because Dolphin doesn't update their shit
      - "ppa:kgilmer/speed-ricer" # Rice rice rice
      - "ppa:lutris-team/lutris" # Lutris is kickass
  - name: Update and upgrade apt packages
    apt:
      upgrade: "yes"
      update_cache: yes
      # One day
      cache_valid_time: 86400
  - name: Install packages
    apt:
      name:
        # Terminal packages
        - adb
        - build-essential
        - cmake
        - debhelper
        - devscripts
        - dh-make
        - earlyoom
        - fastboot
        - ffmpeg
        - git
        - imagemagick
        - libinput-tools
        - lua-check # I am good ComputerCraft guy
        - neofetch
        - network-manager-openconnect
        - network-manager-openvpn
        - network-manager-vpnc # For default route configuration
        - npm
        - openjdk-8-jre # For Minecraft
        - pbuilder
        - pwgen
        - python3-appdirs
        - python3-eyed3
        - python3-pip
        - python3-pyqt5
        - python3-usb # fuselee-gelee
        - python3-venv
        - qt5-default # For Multimc, should be installed on Kubuntu
        - traceroute
        - tree
        - units
        - vim
        - wamerican # Dictionaries because I have like two scripts that use them
        - wamerican-large
        - wamerican-huge
        - wamerican-insane
        - wine
        - wine-binfmt
        - xz-utils # For Ansible deb support
        # Fonts
        - fonts-fork-awesome
        - fonts-inconsolata
        - fonts-material-design-icons-iconfont
        - fonts-noto
        - fonts-roboto
        # DE
        - bspwm
        - compton
        - conky-all
        - dunst
        - hsetroot
        - i3lock
        - ibus
        - ibus-mozc
        - kubuntu-desktop
        - mozc-utils-gui
        - nitrogen
        - papirus-icon-theme
        - pavucontrol-qt
        - polybar
        - qt5ct
        - xbacklight
        # Desktop applications
        - barrier
        - cantata
        - chromium-browser
        - chromium-chromedriver # Because Selenium
        - clonezilla
        - dolphin-emu-master
        - dolphin-plugins
        - element-desktop
        - filelight
        - filezilla
        - firefox
        - g810-led
        - gimp
        - inkscape
        - joy2key
        - joystick
        - kcolorchooser
        - kde-config-plymouth
        - kdenlive
        - kdepim
        - keepassxc
        - krita
        - libnotify-bin
        - libretro-desmume
        - libretro-mgba
        - libretro-mupen64plus
        - libretro-snes9x
        - lutris
        - mesa-vulkan-drivers
        - mono-complete
        - monodevelop
        - mpv
        - mupen64plus-qt
        - nextcloud-desktop
        - obs-studio
        - plymouth-theme-spinner
        - pulseeffects
        - q4wine
        - qbittorrent
        - rdesktop
        - redshift
        - retroarch
        - rofi
        - scrot
        - steam-installer
        - syncthing-gtk
        - telegram-desktop
        - torbrowser-launcher
        - virt-manager
        - vulkan-tools
        - vulkan-utils
        - winetricks
        - xdotool
        - zim
        - "libgl1-mesa-dri:i386"
        - "mesa-vulkan-drivers:i386"
        # Games
        - minetest
  - name: Install System76-exclusive packages
    apt:
      name:
        - firmware-manager
        - kamoso
        - system76-acpi-dkms
        - system76-dkms
        - system76-firmware
        - system76-io-dkms
        - system76-power
    when: ansible_system_vendor == "System76"
  - name: Install Focal-exclusive desktop applications
    apt:
      name:
        - piper
    when: ansible_distribution_release == "focal"
  - name: Install packages without recommends
    apt:
      install_recommends: no
      name:
        - php # Dev stuff
        - php-xml
  - name: Install out-of-repo packages
    apt:
      deb: "{{ item }}"
    loop:
      - "https://github.com/MultiMC/MultiMC5/releases/download/0.6.8/multimc_1.4-1.deb"
      - "https://zoom.us/client/latest/zoom_amd64.deb"
  - name: Install desktop applications through pip3
    pip:
      executable: "/usr/bin/pip3"
      name:
        - protontricks
        - youtube-dl
  - name: Install desktop applications through Snap
    snap:
      name:
        - discord
        - sengi
        - scrcpy # Remote Android viewing
        - spotify # Forgive me father
  - name: Install Snap applications classically
    snap:
      classic: yes
      name: "{{ item }}"
    loop:
      - slack
  - name: Remove Snap applications
    snap:
      name:
        - pixelorama
        - riot-web
      state: absent
  - name: Remove desktop applications through APT
    apt:
      name:
        - ktorrent
        - mpd
        - thunderbird
      state: absent
  become: yes