#!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null;
. "../Config/pacman/install.sh";
. "../Software/yay/install.sh";

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

# Essentials
yay --noconfirm -Syu \
    bash-completion \
    wget \
    oh-my-posh-bin \
    screen \
    tmux \
    htop \
    vim \
    vi-vim-symlink \
    zsh \
    fish;

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

. "../Software/git/install.sh";

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

# 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";

# rclone
. "../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 \
    signal-desktop \
    `# extension-manager` \
    `# easyeffects` \
    threema-desktop \
    `# gnome-tweaks` \
    blackbox-terminal \
    cpu-x \
    libreoffice-fresh;

yay --noconfirm -Syu \
    discord \
    openasar-git;

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

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

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

# Games
yay --noconfirm -Syu \
    steam;

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

# Coding
yay --noconfirm -Syu \
    libdbusmenu-glib;

yay --noconfirm -Syu \
    vscodium-bin \
    vscodium-insiders-bin \
    visual-studio-code-bin \
    visual-studio-code-insiders-bin \
    godot-mono-bin;

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

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

codiumPattern="^exec .*\\/codium ";
sudo sed -i "/$codiumPattern/{ s/\"\$@\"//; s/$codiumPattern/\0\"\$@\" /; }" /usr/bin/codium;

# 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 \
    vim \
    tea \
    woodpecker-cli;

flatpak install flathub com.usebottles.bottles;

popd > /dev/null;