#!/usr/bin/bash
# Deploy the cyberqueer Qt theme files to ~/.config/qt6ct/ and the
# hyprpolkitagent systemd drop-in.  Safe to re-run after reinstalls.
set -euo pipefail

DOTFILES="${DOTFILES:-$HOME/Dotfiles}"
SRC="$DOTFILES/qt-themes/cyberqueer"

# QSS stylesheet for Qt Widgets apps (loaded by qt6ct)
mkdir -p "$HOME/.config/qt6ct/qss"
cp "$SRC/style.qss" "$HOME/.config/qt6ct/qss/style.qss"

# qt6ct color palette (QPalette roles for Fusion style)
mkdir -p "$HOME/.config/qt6ct/colors"
cp "$SRC/cyberqueer.conf" "$HOME/.config/qt6ct/colors/cyberqueer.conf"

# qt6ct config — expand leading ~ to $HOME in file paths
mkdir -p "$HOME/.config/qt6ct"
sed "s|~|$HOME|g" "$SRC/qt6ct.conf" > "$HOME/.config/qt6ct/qt6ct.conf"

# hyprpolkitagent systemd drop-in: Material style + cyberqueer colors
POLKIT_DROP="$HOME/.config/systemd/user/hyprpolkitagent.service.d"
mkdir -p "$POLKIT_DROP"
cp "$SRC/hyprpolkitagent-qt.conf" "$POLKIT_DROP/qt-theme.conf"
systemctl --user daemon-reload || true
systemctl --user restart hyprpolkitagent || true

echo "cyberqueer Qt theme deployed."
