#!/bin/bash
echo "Uninstalling conflicting Packages"
sudo pacman -Rns hyprland-git hyprcursor-git hyprland-qtutils-git hyprutils-git hyprgraphics-git hyprland-workspaces hyprwayland-scanner-git hyprland-workspaces-debug hyprland-qt-support-git hyprlang-git hyprgraphics-git hyprland-qtutils-git hyprlang-git; echo "uninstall completed, now installing"
echo "Installing required Packages"
sudo pacman -Syu hyprland hyprcursor wl-clipboard hyprpaper hyprlock wofi kitty dunst nwg-dock-hyprland nwg-drawer nwg-menu nwg-look python cmake meson cpio pkgconf ruby-pkg-config hyprsunset hypridle ksshaskpass nm-connection-editor network-manager-applet blueman bluez pipewire alsa-utils firefox greetd-tuigreet grim slurp gst-plugin-pipewire imagemagick nerd-fonts otf-font-awesome pipewire-alsa pipewire-jack pipewire-pulse qt5-wayland qt6-wayland swww ttf-jetbrains-mono wireplumber wofi qt6ct xdg-desktop-portal-hyprland xdg-utils xorg-server xorg-xinit papirus-icon-theme cool-retro-term units qalculate-gtk iwd dbus thunar tumbler thunar-archive-plugin thunar-shares-plugin thunar-volman hyprpicker pcmanfm-qt 
echo "Installing AUR packages"
yay -Syu --answerdiff None --answerclean All hyprland-workspaces bluetuith wvkbd kew wofi-calc walker-bin iwmenu bzmenu ulauncher pinta localsend hyprshutdown hyprpwcenter hyprsysteminfo
#qalculate-gtk

rm -rf ~/.config/eww
read -n1 -p "Install eww bar for PC, Notebook or Tablet [P,N,T]" doit 
case $doit in  
  n|N) ln -s ~/Dotfiles/desktopenvs/hyprland/eww/ ~/.config/ ;; 
  p|P)  ln -s ~/Dotfiles/desktopenvs/hyprland/eww-nobattery/ ~/.config/eww ;; 
  t|T)  ln -s ~/Dotfiles/desktopenvs/hyprland/eww-touch/ ~/.config/eww ;; 
  *) echo "enter a valid decision" ;; 
esac

#eww compilation
echo "compiling EWW"
cd ~/install-tmp
git clone https://github.com/elkowar/eww
cd eww
cargo build --release --no-default-features --features=wayland
cd target/release
chmod +x ./eww
sudo cp ./eww /usr/bin

sudo cp -r ~/Dotfiles/gtk-themes/cyberqueer /usr/share/themes
sudo cp ~/Dotfiles/desktopenvs/hyprland/btop/themes/cyberqueer.theme /usr/share/btop/themes
sudo cp -f ~/Dotfiles/desktopenvs/hyprland/greetd-tuigreet/config.toml /etc/greetd/config.toml
sudo ln -s /usr/bin/kitty /usr/bin/xdg-terminal-exec

sudo ln /usr/bin/ksshaskpass /usr/lib/ssh/ssh-askpass
cd ~/install-tmp
mkdir ~/.icons
wget https://github.com/guillaumeboehm/Nordzy-cursors/releases/download/v2.3.0/Nordzy-cursors-lefthand.tar.gz
tar -zxvf Nordzy-cursors-lefthand.tar.gz -C $HOME/.icons/

#tar x -f papirus-icon-theme-violet-folders.tar.xz
#cp -r Papirus* ~/.icons
#gsettings set org.gnome.desktop.interface icon-theme Papirus-Dark

sudo systemctl enable bluez
sudo systemctl enable bluetooth.service
sudo systemctl enable iwd.service
hyprpm update
hyprpm add https://github.com/hyprwm/hyprland-plugins

rm -rf ~/.config/kitty
ln -s ~/Dotfiles/desktopenvs/hyprland/kitty/ ~/.config/

rm -rf ~/.config/mimeapps.list
ln -s ~/Dotfiles/desktopenvs/hyprland/mimeapps.list ~/.config/

rm -rf ~/.config/walker
ln -s ~/Dotfiles/desktopenvs/hyprland/walker/ ~/.config/

rm -rf ~/.config/hypr
ln -s ~/Dotfiles/desktopenvs/hyprland/hypr/ ~/.config/

rm -rf ~/.config/xfce4 
ln -s ~/Dotfiles/desktopenvs/hyprland/xfce4 ~/.config/

rm -rf ~/.config/wofi
ln -s ~/Dotfiles/desktopenvs/hyprland/wofi/ ~/.config/

rm -rf ~/.config/dunst
ln -s ~/Dotfiles/desktopenvs/hyprland/dunst/ ~/.config/

rm -rf ~/.config/alacritty
ln -s ~/Dotfiles/desktopenvs/hyprland/alacritty ~/.config/

rm -rf ~/.config/nwg-dock-hyprland
ln -s ~/Dotfiles/desktopenvs/hyprland/nwg-dock-hyprland ~/.config/

rm -rf ~/.config/nwg-drawer
ln -s ~/Dotfiles/desktopenvs/hyprland/nwg-drawer ~/.config

rm -rf ~/.config/nwg-panel
ln -s ~/Dotfiles/desktopenvs/hyprland/nwg-panel ~/.config

rm -rf ~/.config/ulauncher
cp -s ~/Dotfiles/desktopenvs/hyprland/ulauncher/ ~/.config/

ln -s ~/Dotfiles/desktopenvs/hyprland/scripts ~/.config

rm -rf ~/.config/btop
ln -s ~/Dotfiles/desktopenvs/hyprland/btop ~/.config/
#ln -s ~/Dotfiles/desktopenvs/hyprland/gtk/* ~/.config

rm -rf ~/.config/gtk-3.0
ln -s ~/Dotfiles/desktopenvs/hyprland/gtk-3.0 ~/.config

#ln -s ~/Dotfiles/desktopenvs/hyprland/eww/ ~/.config/
#ln -s ~/Dotfiles/desktopenvs/hyprland/eww-nobattery/ ~/.config/eww

cp ~/Dotfiles/colors.conf ~/.config/colors.conf
cp ~/Dotfiles/apply-theme.sh ~/apply-theme.sh
chmod +x ~/apply-theme.sh

cp ~/Dotfiles/resources/fflogo.svg ~/Pictures/fflogo.svg

cp ~/Dotfiles/desktopenvs/hyprland/hypr-usr/* ~/.config
wget https://cloud.abdelbaki.eu/apps/theming/image/background?v=15 -O ~/Pictures/background.jpg
python -m venv ~/.config/python-script
~/.config/python-script/bin/pip install speedtest-cli requests pint simpleeval parsedatetime


