#!/bin/bash
set -e

REPO_URL="https://repo.roxyproxy.de/roxyos"
REPO_NAME="roxyos"

echo ""
echo "  ██████╗  ██████╗ ██╗  ██╗██╗   ██╗ ██████╗ ███████╗"
echo "  ██╔══██╗██╔═══██╗╚██╗██╔╝╚██╗ ██╔╝██╔═══██╗██╔════╝"
echo "  ██████╔╝██║   ██║ ╚███╔╝  ╚████╔╝ ██║   ██║███████╗"
echo "  ██╔══██╗██║   ██║ ██╔██╗   ╚██╔╝  ██║   ██║╚════██║"
echo "  ██║  ██║╚██████╔╝██╔╝ ██╗   ██║   ╚██████╔╝███████║"
echo "  ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝   ╚═╝    ╚═════╝ ╚══════╝"
echo ""
echo "  Roxy Migurdia themed Niri configuration for Arch Linux"
echo ""

if [[ $EUID -eq 0 ]]; then
    echo "Please run as a regular user, not root."
    exit 1
fi

if ! command -v pacman &> /dev/null; then
    echo "This installer requires Arch Linux (pacman not found)."
    exit 1
fi

echo "Adding RoxyOS repository..."

if ! grep -q "\[$REPO_NAME\]" /etc/pacman.conf; then
    echo ""
    echo "[$REPO_NAME]" | sudo tee -a /etc/pacman.conf > /dev/null
    echo "SigLevel = Optional TrustAll" | sudo tee -a /etc/pacman.conf > /dev/null
    echo "Server = $REPO_URL" | sudo tee -a /etc/pacman.conf > /dev/null
    echo ""
fi

echo "Syncing repositories..."
sudo pacman -Sy

echo "Installing roxyos-setup..."
sudo pacman -S --noconfirm --needed roxyos-setup

echo ""
echo "Launching RoxyOS setup wizard..."
echo ""

roxyos-setup
