#!/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://packagecloud.io/slacktechnologies/slack/gpgkey" # Slack
      - "https://syncthing.net/release-key.txt" # Syncthing
      - "https://packages.riot.im/debian/riot-im-archive-keyring.gpg" # Element
      - "https://download.spotify.com/debian/pubkey.gpg" # Spotify 1
      - "https://download.spotify.com/debian/pubkey_0D811D58.gpg" # Spotify 2
  - name: Add repos
    apt_repository:
      repo: "{{ item }}"
    loop:
      # Debs
      - "deb https://packagecloud.io/slacktechnologies/slack/debian/ jessie main" # Slack
      - "deb http://repository.spotify.com stable non-free" # Spotify
      - "deb https://apt.syncthing.net/ syncthing stable" # Syncthing
      - "deb https://download.mono-project.com/repo/ubuntu vs-bionic main" # Monodevelop
      - "deb https://packages.riot.im/debian/ default main" # Element
      # My PPA
      #- "ppa:rehashedsalt/personal"
      # First-party PPAs
      - "ppa:phoerious/keepassxc" # KeepassXC
      # Third-party PPAs
      - "ppa:system76-dev/stable" # Love my lemp9
      - "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
        - bison
        - build-essential
        - cmake
        - debhelper
        - devscripts # Tons of cool shit in here, mostly for packaging tho
        - dh-make
        - earlyoom
        - fastboot
        - ffmpeg
        - flex
        - git
        - glances # For temperature monitoring, mostly. It's pretty heavy
        - imagemagick
        - libinput-tools # Allows for libinput debugging
        - lua-check # I am good ComputerCraft guy
        - neofetch # I never use it but whatever I guess
        - network-manager-openconnect
        - network-manager-openvpn
        - network-manager-vpnc # For default route configuration
        - nmap # For those times when you wanna scan a guy
        - npm # I'm sorry
        - openjdk-8-jre # For Minecraft
        - pbuilder # Deb creation tool that does it all in a container
        - pwgen
        - python3-appdirs
        - python3-eyed3
        - python3-pip
        - python3-pyqt5
        - python3-usb # fuselee-gelee
        - python3-venv
        - qt5-default # For Multimc, should be installed on Kubuntu by default regardless
        - traceroute
        - tree
        - units # How many bytes are in a mile?
        - vagrant
        - vagrant-libvirt
        - 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
        - conky-all # Why this is in several packages is beyond me
        - dunst
        - hsetroot # Works around a bug with Compton and a gray root window
        - i3lock # Don't actually use this anymore (wew ksmserver)
        - ibus
        - ibus-mozc # Jap
        - kubuntu-desktop # Sanity
        - mozc-utils-gui
        - nitrogen
        - papirus-icon-theme
        - pavucontrol-qt
        - picom
        - polybar
        - qt5ct
        - xbacklight # This works on literally none of my machines but fuck it
        # Desktop applications
        - alsa-tools-gui # For reprobing my front jack, I guess??
        - barrier # FOSS Synergy
        - cantata # MPD client
        - chromium-browser
        - chromium-chromedriver # Because Selenium
        - clonezilla
        - dolphin-emu-master
        - dolphin-plugins
        - element-desktop
        - filelight # Sweet disk usage util
        - filezilla
        - firefox
        - g810-led # For Logitech peripherals
        - gimp
        - inkscape # I use it for like two things
        - joy2key # Neat little wrapper to bind joypad keys to keyboard keys
        - joystick
        - kcolorchooser
        - kde-config-plymouth # Realistically not required, but whatever
        - kdenlive # For the one video I edit a year
        - kdepim
        - keepassxc
        - krita # I don't ever end up using this, maybe I'll pick it up for spritework
        - libnotify-bin # Used for several of my scripts
        - libretro-desmume
        - libretro-mgba
        - libretro-mupen64plus
        - libretro-snes9x
        - lutris
        - mesa-vulkan-drivers
        - mono-complete # Initial installation of this package may take an eternity
        - monodevelop
        - mpv
        - mupen64plus-qt
        - nextcloud-desktop
        - obs-studio
        - plymouth-theme-spinner # Gives us the good UEFI logo bootup
        - pulseeffects # I need to be an echoey boi
        - q4wine
        - qbittorrent
        - rdesktop # CLI RDP client, works real nice
        - redshift
        - retroarch
        - rofi
        - scrot # For scripted screenshots
        - slack-desktop
        - spotify-client
        - steam-installer
        - syncthing-gtk
        - telegram-desktop
        - torbrowser-launcher # Sometimes it's bugged but it's still nice to have
        - virt-manager
        - vulkan-tools
        - vulkan-utils
        - winetricks
        - xdotool
        - xserver-xephyr
        - zim
        # Other architectures, misc
        - "libgl1-mesa-dri:i386"
        - "mesa-vulkan-drivers:i386"
        # Games
        - minetest
  - name: Install System76-exclusive packages
    apt:
      name:
        - firmware-manager
        - kamoso # Camera util
        - 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 # Peripheral LED management
    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://dl.discordapp.net/apps/linux/0.0.12/discord-0.0.12.deb"
      - "https://github.com/MultiMC/MultiMC5/releases/download/0.6.8/multimc_1.4-1.deb"
      - "https://zoom.us/client/latest/zoom_amd64.deb"
    # We ignore errors here in case we have a more up-to-date package on the target machine and/or face a URL timeout
    ignore_errors: yes
  - name: Install desktop applications through pip3
    pip:
      executable: "/usr/bin/pip3"
      state: latest
      name:
        - pmbootstrap
        - protontricks
        - youtube-dl
    # Just in case we have legacy apps floating around
  - name: Remove Snap applications
    snap:
      name:
        - discord
        - pixelorama
        - riot-web
        - slack
        - scrcpy
        - sengi
        - spotify
      state: absent
  - name: Remove desktop applications through APT
    apt:
      name:
        - ktorrent
        - mpd
        - thunderbird
      state: absent
  become: yes