From 5ef5e904d5998fdb7718afd4430507efe15a0673 Mon Sep 17 00:00:00 2001 From: duma799 Date: Wed, 11 Feb 2026 21:04:56 +0400 Subject: [PATCH] Remove unnecessary comments --- waypaper-hook.sh | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/waypaper-hook.sh b/waypaper-hook.sh index 1e79bb3..3bd3ca7 100755 --- a/waypaper-hook.sh +++ b/waypaper-hook.sh @@ -1,14 +1,10 @@ #!/bin/bash -# Waypaper post-change hook - automatically applies pywal colors when wallpaper changes -# This runs every time you change wallpaper in waypaper +# Waypaper hook - applies pywal colors on wallpaper change -# Lock file to prevent multiple simultaneous runs LOCK_FILE="/tmp/waypaper-hook.lock" LOG_FILE="/tmp/waypaper-hook.log" -# Check if already running if [ -f "$LOCK_FILE" ]; then - # Check if the process is actually running LOCK_PID=$(cat "$LOCK_FILE" 2>/dev/null) if [ -n "$LOCK_PID" ] && kill -0 "$LOCK_PID" 2>/dev/null; then echo "Hook already running (PID: $LOCK_PID), skipping..." >> "$LOG_FILE" @@ -16,72 +12,56 @@ if [ -f "$LOCK_FILE" ]; then fi fi -# Create lock file echo $$ > "$LOCK_FILE" - -# Cleanup lock file on exit trap "rm -f $LOCK_FILE" EXIT echo "=== Waypaper hook triggered at $(date) ===" >> "$LOG_FILE" -# Wait a moment for waypaper to finish writing config sleep 0.5 -# Method 1: Get wallpaper from waypaper config +# Get wallpaper from waypaper config WALLPAPER=$(grep "^wallpaper = " ~/.config/waypaper/config.ini | cut -d' ' -f3-) WALLPAPER="${WALLPAPER/#\~/$HOME}" -# Method 2: Get from swaybg process as fallback +# Fallback: swaybg process if [ ! -f "$WALLPAPER" ]; then - echo "Trying to get wallpaper from swaybg process..." >> "$LOG_FILE" WALLPAPER=$(pgrep -a swaybg | grep -oP '(?<=-i )[^ ]+' | head -1) fi if [ -f "$WALLPAPER" ]; then echo "Applying pywal for wallpaper: $WALLPAPER" >> "$LOG_FILE" - # Generate pywal colors from new wallpaper - # Use --backend wal to avoid hanging, -n to skip setting wallpaper, -s to skip reloading wal -i "$WALLPAPER" --backend wal -n -s -t >> "$LOG_FILE" 2>&1 - # Apply colors system-wide (run in background to avoid blocking) ( - # Update Caelestia if [ -f ~/.cache/wal/caelestia-scheme.json ]; then mkdir -p ~/.local/state/caelestia cp ~/.cache/wal/caelestia-scheme.json ~/.local/state/caelestia/scheme.json - # Sync Caelestia wallpaper mkdir -p ~/.local/state/caelestia/wallpaper ln -sf "$WALLPAPER" ~/.local/state/caelestia/wallpaper/current echo "$WALLPAPER" > ~/.local/state/caelestia/wallpaper/path.txt fi - # Restart Caelestia shell if pgrep -x "caelestia" > /dev/null; then pkill caelestia sleep 0.5 caelestia shell -d & fi - # Reload Hyprland hyprctl reload > /dev/null 2>&1 - # Reload all running Kitty instances if pgrep -x "kitty" > /dev/null; then killall -SIGUSR1 kitty 2>/dev/null fi - # Update GTK themes if available if command -v wal-gtk &> /dev/null; then wal-gtk >> "$LOG_FILE" 2>&1 fi - # Set GTK dark mode preference if available if command -v gsettings &> /dev/null; then gsettings set org.gnome.desktop.interface color-scheme "prefer-dark" 2>/dev/null fi - # Update Firefox if available if command -v pywalfox &> /dev/null; then pywalfox update &>/dev/null & fi