diff options
| author | Donald Williams <129223418+dwilliam62@users.noreply.github.com> | 2025-09-20 12:39:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-20 12:39:50 -0400 |
| commit | 70cb2274b35516802c1ee77b56f50f81ab68d32a (patch) | |
| tree | d113657da876303204f5d53a0736421ca33a36f7 | |
| parent | 163ae337133a524ef2340cfbcaba8ee9d37bc413 (diff) | |
| parent | 88f1b4d4ebbcdb58daecbbee2c0cdab791366452 (diff) | |
Merge branch 'development' into qs_overview_fix_v2
| -rw-r--r-- | config/hypr/UserConfigs/UserSettings.conf | 3 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperAutoChange.sh | 5 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperSelect.sh | 4 | ||||
| -rwxr-xr-x | config/hypr/scripts/RefreshNoWaybar.sh | 5 | ||||
| -rwxr-xr-x | config/hypr/scripts/WallustSwww.sh | 75 | ||||
| -rwxr-xr-x | config/hypr/scripts/WaybarCava.sh | 51 | ||||
| -rwxr-xr-x | config/swaync/config.json | 4 |
7 files changed, 91 insertions, 56 deletions
diff --git a/config/hypr/UserConfigs/UserSettings.conf b/config/hypr/UserConfigs/UserSettings.conf index 2ba23acc..f31bb7e1 100644 --- a/config/hypr/UserConfigs/UserSettings.conf +++ b/config/hypr/UserConfigs/UserSettings.conf @@ -64,8 +64,7 @@ input { } gestures { - workspace_swipe = true - workspace_swipe_fingers = 3 + gesture = 3, horizontal, workspace workspace_swipe_distance = 500 workspace_swipe_invert = true workspace_swipe_min_speed_to_force = 30 diff --git a/config/hypr/UserScripts/WallpaperAutoChange.sh b/config/hypr/UserScripts/WallpaperAutoChange.sh index f54620bb..a6d2cedd 100755 --- a/config/hypr/UserScripts/WallpaperAutoChange.sh +++ b/config/hypr/UserScripts/WallpaperAutoChange.sh @@ -31,7 +31,10 @@ while true; do done \ | sort -n | cut -d':' -f2- \ | while read -r img; do - swww img -o $focused_monitor "$img" + swww img -o $focused_monitor "$img" + # Regenerate colors from the exact image path to avoid cache races + $HOME/.config/hypr/scripts/WallustSwww.sh "$img" + # Refresh UI components that depend on wallust output $wallust_refresh sleep $INTERVAL diff --git a/config/hypr/UserScripts/WallpaperSelect.sh b/config/hypr/UserScripts/WallpaperSelect.sh index a6e6c4d4..a08b53ce 100755 --- a/config/hypr/UserScripts/WallpaperSelect.sh +++ b/config/hypr/UserScripts/WallpaperSelect.sh @@ -168,8 +168,8 @@ apply_image_wallpaper() { swww img -o "$focused_monitor" "$image_path" $SWWW_PARAMS - # Run additional scripts - "$SCRIPTSDIR/WallustSwww.sh" + # Run additional scripts (pass the image path to avoid cache race conditions) + "$SCRIPTSDIR/WallustSwww.sh" "$image_path" sleep 2 "$SCRIPTSDIR/Refresh.sh" sleep 1 diff --git a/config/hypr/scripts/RefreshNoWaybar.sh b/config/hypr/scripts/RefreshNoWaybar.sh index f950db51..8454124e 100755 --- a/config/hypr/scripts/RefreshNoWaybar.sh +++ b/config/hypr/scripts/RefreshNoWaybar.sh @@ -31,8 +31,9 @@ done # quit quickshell & relaunch quickshell #pkill qs && qs & -# Wallust refresh -${SCRIPTSDIR}/WallustSwww.sh & +# Wallust refresh (synchronous to ensure colors are ready) +${SCRIPTSDIR}/WallustSwww.sh +sleep 0.2 # reload swaync swaync-client --reload-config diff --git a/config/hypr/scripts/WallustSwww.sh b/config/hypr/scripts/WallustSwww.sh index 62dde375..5a0bc491 100755 --- a/config/hypr/scripts/WallustSwww.sh +++ b/config/hypr/scripts/WallustSwww.sh @@ -1,39 +1,58 @@ #!/bin/bash # /* ---- π« https://github.com/JaKooLit π« ---- */ ## -# Wallust Colors for current wallpaper +# Wallust: derive colors from the current wallpaper and update templates +# Usage: WallustSwww.sh [absolute_path_to_wallpaper] -# Define the path to the swww cache directory +set -euo pipefail + +# Inputs and paths +passed_path="${1:-}" cache_dir="$HOME/.cache/swww/" +rofi_link="$HOME/.config/rofi/.current_wallpaper" +wallpaper_current="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" -# Get a list of monitor outputs -monitor_outputs=($(ls "$cache_dir")) +# Helper: get focused monitor name (prefer JSON) +get_focused_monitor() { + if command -v jq >/dev/null 2>&1; then + hyprctl monitors -j | jq -r '.[] | select(.focused) | .name' + else + hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}' + fi +} -# Initialize a flag to determine if the ln command was executed -ln_success=false +# Determine wallpaper_path +wallpaper_path="" +if [[ -n "$passed_path" && -f "$passed_path" ]]; then + wallpaper_path="$passed_path" +else + # Try to read from swww cache for the focused monitor, with a short retry loop + current_monitor="$(get_focused_monitor)" + cache_file="$cache_dir$current_monitor" -# Get current focused monitor -current_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}') -echo $current_monitor -# Construct the full path to the cache file -cache_file="$cache_dir$current_monitor" -echo $cache_file -# Check if the cache file exists for the current monitor output -if [ -f "$cache_file" ]; then - # Get the wallpaper path from the cache file - wallpaper_path=$(grep -v 'Lanczos3' "$cache_file" | head -n 1) - echo $wallpaper_path - # symlink the wallpaper to the location Rofi can access - if ln -sf "$wallpaper_path" "$HOME/.config/rofi/.current_wallpaper"; then - ln_success=true # Set the flag to true upon successful execution + # Wait briefly for swww to write its cache after an image change + for i in {1..10}; do + if [[ -f "$cache_file" ]]; then + break fi - # copy the wallpaper for wallpaper effects - cp -r "$wallpaper_path" "$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" + sleep 0.1 + done + + if [[ -f "$cache_file" ]]; then + # The first non-filter line is the original wallpaper path + wallpaper_path="$(grep -v 'Lanczos3' "$cache_file" | head -n 1)" + fi fi -# Check the flag before executing further commands -if [ "$ln_success" = true ]; then - # execute wallust - echo 'about to execute wallust' - # execute wallust skipping tty and terminal changes - wallust run "$wallpaper_path" -s & +if [[ -z "${wallpaper_path:-}" || ! -f "$wallpaper_path" ]]; then + # Nothing to do; avoid failing loudly so callers can continue + exit 0 fi + +# Update helpers that depend on the path +ln -sf "$wallpaper_path" "$rofi_link" || true +mkdir -p "$(dirname "$wallpaper_current")" +cp -f "$wallpaper_path" "$wallpaper_current" || true + +# Run wallust (silent) to regenerate templates defined in ~/.config/wallust/wallust.toml +# -s is used in this repo to keep things quiet and avoid extra prompts +wallust run -s "$wallpaper_path" || true diff --git a/config/hypr/scripts/WaybarCava.sh b/config/hypr/scripts/WaybarCava.sh index d31a05b5..6809e60e 100755 --- a/config/hypr/scripts/WaybarCava.sh +++ b/config/hypr/scripts/WaybarCava.sh @@ -1,26 +1,42 @@ -#!/bin/bash -# /* ---- π« https://github.com/JaKooLit π« ---- */ ## -# Not my own work. This was added through Github PR. Credit to original author +#!/usr/bin/env bash +# WaybarCava.sh β safer single-instance handling, cleanup, and robustness +# Original concept by JaKooLit; this variant focuses on lifecycle hardening. -#----- Optimized bars animation without much CPU usage increase -------- +set -euo pipefail + +# Ensure cava exists +if ! command -v cava >/dev/null 2>&1; then + echo "cava not found in PATH" >&2 + exit 1 +fi + +# 0..7 β βββββ
βββ bar="βββββ
βββ" dict="s/;//g" - -# Calculate the length of the bar outside the loop bar_length=${#bar} - -# Create dictionary to replace char with bar for ((i = 0; i < bar_length; i++)); do - dict+=";s/$i/${bar:$i:1}/g" + dict+=";s/$i/${bar:$i:1}/g" done -# Create cava config -config_file="/tmp/bar_cava_config" +# Single-instance guard (only kill our previous instance if itβs still alive) +RUNTIME_DIR="${XDG_RUNTIME_DIR:-/tmp}" +pidfile="$RUNTIME_DIR/waybar-cava.pid" +if [[ -f "$pidfile" ]]; then + oldpid="$(cat "$pidfile" || true)" + if [[ -n "$oldpid" ]] && kill -0 "$oldpid" 2>/dev/null; then + kill "$oldpid" 2>/dev/null || true + sleep 0.1 || true + fi +fi +printf '%d' $$ >"$pidfile" + +# Unique temp config + cleanup on exit +config_file="$(mktemp "$RUNTIME_DIR/waybar-cava.XXXXXX.conf")" +cleanup() { rm -f "$config_file" "$pidfile"; } +trap cleanup EXIT INT TERM + cat >"$config_file" <<EOF [general] -# Older systems show significant CPU use with default framerate -# Setting maximum framerate to 30 -# You can increase the value if you wish framerate = 30 bars = 10 @@ -35,8 +51,5 @@ data_format = ascii ascii_max_range = 7 EOF -# Kill cava if it's already running -pkill -f "cava -p $config_file" - -# Read stdout from cava and perform substitution in a single sed command -cava -p "$config_file" | sed -u "$dict" +# Stream cava output and translate digits 0..7 to bar glyphs +exec cava -p "$config_file" | sed -u "$dict" diff --git a/config/swaync/config.json b/config/swaync/config.json index 2ec0f771..0aa1af40 100755 --- a/config/swaync/config.json +++ b/config/swaync/config.json @@ -23,7 +23,7 @@ "control-center-width": 450, "control-center-height": 720, "keyboard-shortcuts": true, - "image-visibility": "when available", + "image-visibility": "when-available", "transition-time": 200, "hide-on-clear": false, "hide-on-action": true, @@ -89,4 +89,4 @@ ] } } -}
\ No newline at end of file +} |
