#!/bin/sh

echo "
==> Setting up arch4edu & yay
"

git clone https://aur.archlinux.org/yay
cd yay
makepkg -si
cd ..
rm -rf yay

reflector -c 'Switzerland, Germany' --sort 'rate' --protocol https --latest 10 --save /etc/pacman.d/mirrorlist
echo "Server = https://at.arch4edu.mirror.kescher.at/\$arch" >/etc/pacman.d/mirrorlist

sudo cp ./system/pacman.conf /etc/pacman.conf

sudo pacman-key --recv-keys 7931B6D628C8D3BA
sudo pacman-key --finger 7931B6D628C8D3BA
sudo pacman-key --lsign-key 7931B6D628C8D3BA

# Hyprland
echo "
==> Installing Hyprland
"
sleep 2
yay -S --noconfirm --noremovemake hyprland hypridle hyprfreeze hyprlock aylurs-gtk-shell brightnessctl pulsemixer xdg-desktop-portal-hyprland cliphist grimblast wl-clipboard polkit-gnome swaybg polkit-kde-agent grim rofi cpio sysstat

# Audio, drivers
echo "
==> Installing drivers...
"
sleep 2
yay -S --noconfirm --noremovemake pipewire pipewire-alsa pipewire-pulse pipewire-jack mesa wireplumber trash-cli sensors radeontop lm-sensors smartmontools

# Tools
echo "
==> Installing tools...
"
sleep 2

yay -S --noconfirm --noremovemake fish fzf ouch zathura zathura-pdf-poppler wget vimiv zoxide thunar yazi gnome-tweaks lxappearance gnome-keyring ffmpeg network-manager-applet cpupower-gui python-tkinter acpi python-pillow seahorse man man-pages ntp

# Set up yazi
echo "
==> Setting up yazi...
"
sleep 2
ya pkg add ndtoan96/ouch
ya pkg add boydaihungst/restore
ya pkg add yazi-rs/plugins:vcs-files

# Fonts
echo "
==> Installing fonts...
"
sleep 2
yay -S --noconfirm --noremovemake adobe-source-code-pro-fonts gnome-font-viewer gnome-characters ttf-fantasque-nerd ttf-jetbrains-mono-nerd ttf-fluentui-system-icons ttf-comfortaa candy-icons

# Programming
echo "
==> Installing coding tools...
"
sleep 2
yay -S --noconfirm --noremovemake docker vscodium kitty fish docker terminator bvi nodejs npm python-pip git-credential-manager-bin wine kate rustup cargo filezilla php jdk ripgrep

# nvim
echo "
==> Installing nvim...
"
sleep 2
yay -S --noconfirm --noremovemake neovim lua lua-language-server tree-sitter tree-sitter-cli texlab stylua luarocks jdtls perl julia pyright vscode-css-languageserver vscode-html-languageserver bash-language-server python-black proselint asmfmt typescript-language-server shfmt sass ruby eslint_d nvimpager
sudo npm i -g @vue/typescript-plugin

# Internet
echo "
==> Installing internet programs...
"
sleep 2
yay -S --noconfirm --noremovemake librewolf-bin vesktop-bin thunderbird rustdesk brave-bin

# Utilities
echo "
==> Installing other utilities...
"
sleep 2
yay -S --noconfirm --noremovemake okular vlc nextcloud-client p7zip zip unzip noto-fonts pavucontrol light fastfetch bashtop hugo uxplay upower gdu dig nwg-look serpl fcitx5 qalculate-gtk openconnect light blueman xdg-desktop-portal-termfilechooser-hunkyburrito-git lazygit tldr cloc usbutils bluez-utils bluez

# LaTeX
echo "
==> Installing LaTeX...
"
sleep 2
yay -S --noconfirm --noremovemake texlive biber texlive-latexextra perl-yaml-tiny perl-file-homedir libxcrypt-compat

# WebDev utilities
echo "
==> Installing webdev utilities...
"
sleep 2
sudo npm i -g create-vue sitemap-generator-cli http-server

echo "
==> Doing system config...
"
sleep 2
sudo cp ./system/greetd/config.toml /etc/greetd/config.toml
chsh -s /bin/fish
sudo systemctl enable greetd

cd ./build/
npm i
cd ..

cd ./config/astal/
mkdir node_modules && cd node_modules && ln -sf /usr/share/astal/gjs/ ./astal
cd ../../config/ags/notifications/
mkdir node_modules && cd node_modules && ln -sf /usr/share/astal/gjs/ ./astal
cd ~/projects/dotfiles/

./setup

cd ~/projects/
git clone https://git.janishutz.com/janishutz/nvim
cd nvim
./nvim-install.sh

xdg-settings set default-web-browser librewolf.desktop
xdg-mime default org.pwmt.zathura.desktop application/pdf
sudo systemctl disable rustdesk
sudo systemctl enable --now systemd-timesyncd
hyprpm update

git-credential-manager configure

echo "

==> DONE!

Run the postinstall script after a reboot and logging into NextCloud
to install the grub theme and cursor icons.
Use GNOME Tweaks and nwg-look to change the necessary appearance settings. 
"
