#!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null;

# Firmware
yay --noconfirm -Syu mkinitcpio-firmware;

# Essentials
yay --noconfirm -Syu \
    neofetch \
    tldr \
    bash-completion \
    wget \
    oh-my-posh-bin \
    screen \
    tmux \
    htop \
    btop \
    nvtop \
    lsof \
    zsh \
    fish \
    powershell-bin \
    pkgfile \
    zoxide \
    fzf \
    sl \
    terminal-parrot \
    rar \
    ;

sudo pkgfile --update;

. "../Software/openssh/install.sh";
. "../Software/vim/install.sh";
. "../Software/git/install.sh";
. "../Software/aliae/install.sh";

sudo chsh $USER --shell "$(which fish)";

# User Interface
. ../Software/KDE/install.sh;
. ../Software/sddm/install.sh;

yay --noconfirm -Syu \
    maliit-keyboard \
    ;

yay --noconfirm -Syu power-profiles-daemon;
sudo systemctl enable --now power-profiles-daemon;

# GUI Applications
yay --noconfirm -Syu \
    dconf-editor \
    flatpak \
    `# Fixes: https://www.reddit.com/r/flatpak/comments/168tav2/how_to_fix_blurry_flatpaks_on_high_resolution/` \
    xdg-desktop-portal-gtk \
    ;

# Networking
yay --noconfirm -Syu \
    networkmanager-openvpn \
    networkmanager-openconnect \
    ;

# Fonts
yay --noconfirm -Syu \
    ttf-cascadia-code-nerd \
    ttf-ms-win11-auto \
    otf-cascadia-code \
    ttf-droid \
    ;

# GRUB Shenanigans
. "../Software/minegrub-theme/install.sh";

# # Gnome Extensions
# yay --noconfirm -Syu \
#     gnome-shell-extension-order-icons-git \
#     gnome-shell-extension-desktop-icons-ng \
#     gnome-shell-extension-dash-to-dock \
#     gnome-shell-extension-pop-shell-git \
#     gnome-shell-extension-pano-git;

# . "../Config/GnomeExtensions/install.sh";

# Frameworks
. "../Software/IcedTea/install.sh";

# File Sync
yay --noconfirm -Syu nextcloud-client;
. "../Software/rclone/install.sh";

# Firefox
. "../Software/Firefox/install.sh";

# Brave Browser
yay --noconfirm -Syu \
    brave-bin \
    `# brave-beta-bin` \
    `# brave-nightly-bin` \
    ;

braveExtensions="/opt/brave-bin/extensions";

yay --noconfirm -Syu jq;

BROWSER_BIN="brave" \
EXTENSION_DIR="/usr/share/chromium-extensions" \
EXTENSION_POLICY_DIR="$braveExtensions" \
    source "../../Common/Config/Chromium/install-ytmusic-dl.sh";

# sudo ln -sf "$braveExtensions" /opt/brave.com/brave-beta/extensions;
# sudo ln -sf "$braveExtensions" /opt/brave.com/brave-nightly/extensions;

# Pennywise
source "../Software/Pennywise/install.sh";

# Tools
yay --noconfirm -Rs typescript || true;
yay --noconfirm -Rs yarn || true;
yay --noconfirm -Rs nodejs || true;

yay --noconfirm -Syu \
    bitwarden \
    keepass \
    keepassxc \
    signal-desktop \
    threema-desktop \
    discord \
    openasar-git \
    `# extension-manager` \
    `# easyeffects` \
    `# gnome-tweaks` \
    anki-bin \
    cpu-x \
    libreoffice-fresh \
    gnome-calculator \
    pdfarranger \
    img2pdf \
    protonvpn \
    yubikey-manager-qt \
    ;

yay --noconfirm -Syu \
    blackbox-terminal \
    || \
    sudo flatpak install --system -y \
        com.raggesilver.BlackBox \
    ;

yay --noconfirm -Syu \
    mupdf-tools \
    naps2-bin \
    protonmail-bridge-bin \
    thunderbird \
    ;

. "../Software/waydroid/install.sh";
. "../../Common/Software/nuke-usb/install.sh";

# Python
yay --noconfirm -Syu \
    python \
    python-pip \
    pyenv \
    python-pipenv;

. "../../Common/Config/pyenv/install.sh";

# Media
. "../Software/ytmdesktop/install.sh";

yay --noconfirm -Syu \
    gimp \
    inkscape \
    netflix \
    spotube-bin \
    stremio \
    tidal-dl \
    tidal-hifi-bin \
    nuclear-player-bin \
    audius-client-bin \
    ;

# Games
yay --noconfirm -Syu \
    steam \
    chiaki \
    osu-lazer-bin \
    libretro \
    supertux \
    gamepad-tool-bin \
    ;

. "../Software/Lutris/install.sh";

# Coding
yay --noconfirm -Syu \
    archiso \
    `# ISO support for wimlib` \
    cdrkit \
    wimlib \
    devdocs-desktop \
    python-docutils \
    esbonio \
    godot-mono-bin \
    `# Trash functionality for code` \
    gvfs \
    vscodium-bin \
    vscodium-insiders-bin \
    visual-studio-code-bin \
    visual-studio-code-insiders-bin \
    ;

for editor_bin in \
    codium \
    codium-insiders \
    code \
    code-insiders
do
    for extension in \
        zokugun.sync-settings \
        zokugun.vsix-manager
    do
        $editor_bin --install-extension "$extension";
    done;
done;

{
    echo "--touch-events";
} | tee ~/.config/codium-flags.conf > /dev/null;

cp ~/.config/codium-flags.conf ~/.config/code-flags.conf;

# Node.js
yay --noconfirm -Syu nodejs-n;
sudo n install latest;

# Docker
. "../Software/docker/install.sh";

# Misc
. "../Software/logo-ls/install.sh";
. "../Software/Virtual Machine Manager/install.sh";

yay --noconfirm -Syu \
    bb \
    tea \
    woodpecker-cli \
    `# RDP support for Remmina` \
    freerdp \
    remmina \
    wireshark-qt \
    linux-wifi-hotspot \
    pdf2svg \
    tnef \
    propertree-git \
    ;

flatpak install -y flathub com.usebottles.bottles;

popd > /dev/null;