#!/usr/bin/env bash# install-theme.sh — dispatch the Rosé Pine desktop profile for GNOME/Ubuntu,# or apply the XFCE palette and GTK/xfwm theme on Kali/XFCE. On unsupported# desktops it prints a notice and exits 0 so install.sh can call it safely.## Idempotent. The terminal palette is fully shipped here; the GTK/xfwm themes# are cloned from upstream best-effort (a clone failure is non-fatal).set -u
THEME_SRC=$(cd"$(dirname "$0")"&&pwd)GTK_REPO="${PE_GTK_THEME_REPO:-https://github.com/Fausto-Korpsvart/Rose-Pine-GTK-Theme.git}"GTK_THEME_NAME="${PE_GTK_THEME_NAME:-Rose-Pine-Main-BL}"say(){printf'\033[38;2;156;207;216m[theme]\033[0m %s\n'"$*"; }warn(){printf'\033[38;2;246;193;119m[theme] %s\033[0m\n'"$*" >&2; }# GNOME has its own guarded, reversible installer. Schema probing makes this# work on both stock GNOME and Ubuntu GNOME without hard-coding a release.desktop_hint=${XDG_CURRENT_DESKTOP:-${DESKTOP_SESSION:-}}desktop_hint=${desktop_hint,,}gnome_active=0if[[$desktop_hint== *gnome* ||$desktop_hint== *ubuntu* ]]; thengnome_active=1elif[[ -z $desktop_hint]]&&command -v pgrep >/dev/null 2>&1\&& pgrep -x gnome-shell >/dev/null 2>&1; thengnome_active=1fiif["$(uname -s)"= Linux ]&&(( gnome_active ))\&&command -v gsettings >/dev/null 2>&1; thenexec"$THEME_SRC/install-gnome.sh""$@"fi# --- guard: must be Linux with XFCE tooling ---------------------------------if["$(uname -s)" != Linux ]|| ! command -v xfconf-query >/dev/null 2>&1; then warn "not an XFCE/Linux host (no xfconf-query) — skipping desktop theming." warn "the xfce4-terminal palette in $THEME_SRC/xfce4-terminal/terminalrc is Kali-only."exit0fi# --- 1. xfce4-terminal palette ----------------------------------------------TERM_DST="$HOME/.config/xfce4/terminal"mkdir -p "$TERM_DST"[ -f "$TERM_DST/terminalrc"]&& cp -f "$TERM_DST/terminalrc""$TERM_DST/terminalrc.bak.$(date +%s)"cp -f "$THEME_SRC/xfce4-terminal/terminalrc""$TERM_DST/terminalrc"say "xfce4-terminal Rose Pine palette installed"# Make Alacritty the XFCE default terminal (its Rose Pine config is deployed by# install.sh). Affects "Open Terminal Here" and xfce4 keyboard shortcuts.ifcommand -v alacritty >/dev/null 2>&1; thenHELPERS="$HOME/.config/xfce4/helpers.rc" mkdir -p "$HOME/.config/xfce4"if grep -q '^TerminalEmulator='"$HELPERS"2>/dev/null; then sed -i 's/^TerminalEmulator=.*/TerminalEmulator=alacritty/'"$HELPERS"elseecho'TerminalEmulator=alacritty' >> "$HELPERS"fi say "Alacritty set as XFCE default terminal"fi# --- 2. GTK + xfwm4 themes (best-effort clone) ------------------------------mkdir -p "$HOME/.themes"if[ ! -d "$HOME/.themes/$GTK_THEME_NAME"]; thenifcommand -v git >/dev/null 2>&1; then_tmp=$(mktemp -d)if git clone --depth 1"$GTK_REPO""$_tmp" >/dev/null 2>&1; then# repo layout: themes/<variants>. Copy every Rose-Pine* variant.if[ -d "$_tmp/themes"]; then cp -rf "$_tmp"/themes/* "$HOME/.themes/"2>/dev/null
else cp -rf "$_tmp"/Rose-Pine* "$HOME/.themes/"2>/dev/null
fi say "cloned Rose Pine GTK/xfwm themes into ~/.themes"else warn "could not clone $GTK_REPO — GTK/xfwm theme skipped (terminal palette still applied)"fi rm -rf "$_tmp"else warn "git not found — GTK/xfwm theme skipped"fifi# --- 3. apply via xfconf (only if the theme is present) ---------------------apply(){ xfconf-query -c "$1" -p "$2" -s "$3"2>/dev/null \|| xfconf-query -c "$1" -p "$2" -n -t string -s "$3"2>/dev/null || true; }if[ -d "$HOME/.themes/$GTK_THEME_NAME"]; then apply xsettings /Net/ThemeName "$GTK_THEME_NAME" apply xfwm4 /general/theme "$GTK_THEME_NAME" say "applied GTK + xfwm4 theme: $GTK_THEME_NAME"else warn "theme '$GTK_THEME_NAME' not in ~/.themes — set PE_GTK_THEME_NAME to match the cloned folder, then re-run"fi# dark preference + a readable mono font for window titlesapply xsettings /Net/EnableEventSounds 0say "Rose Pine theming complete. Restart xfce4-terminal / re-login for full effect."