#!/usr/bin/env bash
set -euo pipefail

echo ">>> Installing Hyprland + UWSM"
sudo pacman -S --noconfirm hyprland uwsm

echo ">>> Updating ~/.bash_profile for auto-start"
BASH_PROFILE="$HOME/.bash_profile"

# Ensure file exists
touch "$BASH_PROFILE"

# Insert Hyprland autostart block if not already present
if ! grep -q "uwsm start hyprland.desktop" "$BASH_PROFILE"; then
    cat <<'EOF' >> "$BASH_PROFILE"

# Auto-start Hyprland via UWSM
if uwsm check may-start; then
    exec uwsm start hyprland.desktop
fi
EOF
fi

echo ">>> Installing portal + polkit"
sudo pacman -S --noconfirm xdg-desktop-portal-hyprland hyprpolkitagent

echo ">>> Installing fonts"
sudo pacman -S --noconfirm noto-fonts noto-fonts-emoji

echo ">>> Installing PipeWire audio stack"
sudo pacman -S --noconfirm pipewire-pulse pipewire-alsa pipewire-jack pipewire

echo ">>> Installing basic tools"
sudo pacman -S --noconfirm firefox kitty dolphin waybar mako wofi hyperpaper otf-font-awesome

echo ">>> Rebooting"
sudo reboot