quickshell-rice/quickshell/refresh-quickshell

75 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# ==============================================================================
# refresh-quickshell
# Automatic repository stash, pull, config sync, and QuickShell service restarter
# ==============================================================================
set -e
BOLD='\033[1m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
echo -e "${CYAN}${BOLD}[refresh-quickshell]${NC} Stashing local changes and pulling latest updates..."
THEMES_DIR="${HOME}/Documents/themes"
if [ -d "$THEMES_DIR/.git" ]; then
git -C "$THEMES_DIR" stash || true
git -C "$THEMES_DIR" pull origin main || echo -e "${YELLOW}${BOLD}[WARNING]${NC} Git pull finished with warnings."
echo -e "${GREEN}${BOLD}[SUCCESS]${NC} Git repository pulled from main!"
else
echo -e "${YELLOW}${BOLD}[WARNING]${NC} Git repository not found at ${THEMES_DIR}"
fi
echo -e "${CYAN}${BOLD}[refresh-quickshell]${NC} Syncing configurations to ~/.config/quickshell..."
mkdir -p "${HOME}/.config/quickshell"
if [ -d "$THEMES_DIR/quickshell" ]; then
rsync -av --exclude='tmp' "$THEMES_DIR/quickshell/" "${HOME}/.config/quickshell/"
fi
if [ -d "$THEMES_DIR/fastfetch" ]; then
mkdir -p "${HOME}/.config/fastfetch"
rsync -av "$THEMES_DIR/fastfetch/" "${HOME}/.config/fastfetch/"
fi
echo -e "${CYAN}${BOLD}[refresh-quickshell]${NC} Restarting QuickShell and desktop services..."
if systemctl --user is-active --quiet quickshell.service 2>/dev/null; then
systemctl --user restart quickshell.service
echo -e "${GREEN}${BOLD}[SUCCESS]${NC} QuickShell systemd service restarted!"
else
killall quickshell 2>/dev/null || true
pkill -f active_window_service.py 2>/dev/null || true
pkill -f recolor_watcher.py 2>/dev/null || true
sleep 0.5
QUICKSHELL_BIN="$(command -v quickshell 2>/dev/null || echo 'quickshell')"
nohup "$QUICKSHELL_BIN" >/dev/null 2>&1 &
nohup python3 "${HOME}/.config/quickshell/services/python/active_window_service.py" >/dev/null 2>&1 &
nohup python3 "${HOME}/.config/quickshell/services/python/recolor_watcher.py" >/dev/null 2>&1 &
echo -e "${GREEN}${BOLD}[SUCCESS]${NC} QuickShell background processes restarted!"
fi
# Run theme sync engine to ensure active theme applies across all apps
THEME_SYNC_SCRIPT="${HOME}/.config/quickshell/services/python/theme_sync.py"
if [ -f "$THEME_SYNC_SCRIPT" ]; then
python3 "$THEME_SYNC_SCRIPT" \
--bg "#22212c" \
--surface "#2b2938" \
--currentLine "#454158" \
--fg "#f8f8f2" \
--accent "#9580ff" \
--subAccent "#ff80bf" \
--isDark true \
--variantName Pro 2>/dev/null || true
fi
echo -e "${GREEN}${BOLD}=========================================================="
echo " QuickShell Ecosystem Successfully Refreshed! "
echo "=========================================================="${NC}