Make color env change with wallpaper too
This commit is contained in:
@@ -5,43 +5,49 @@ WALLPAPERS="$HOME/Pictures/Wallpaper"
|
|||||||
CACHE_DIR="$HOME/.cache/wallpaper-picker"
|
CACHE_DIR="$HOME/.cache/wallpaper-picker"
|
||||||
THUMB_WIDTH="250"
|
THUMB_WIDTH="250"
|
||||||
THUMB_HEIGHT="141"
|
THUMB_HEIGHT="141"
|
||||||
THEMES="$HOME/.config/wal/themes"
|
THEMES="$HOME/.config/wal/themes" # still used for name/branding, not applied
|
||||||
WAL_BIN="/usr/local/bin/wal"
|
|
||||||
HOOKS="$HOME/.config/wal/hooks/hooks.sh"
|
HOOKS="$HOME/.config/wal/hooks/hooks.sh"
|
||||||
FASTFETCH_CFG="$HOME/.config/fastfetch/config.jsonc"
|
FASTFETCH_CFG="$HOME/.config/fastfetch/config.jsonc"
|
||||||
|
|
||||||
|
# WAL — resolve real binary dynamically (fixes manual mismatch)
|
||||||
|
WAL_BIN="$(command -v wal)"
|
||||||
|
if [[ -z "$WAL_BIN" ]]; then
|
||||||
|
notify-send "Wallpaper Picker" "pywal (wal) not found in PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Make the thumb dir if it's not exist
|
# Make the thumb dir if it's not exist
|
||||||
mkdir -p "$CACHE_DIR"
|
mkdir -p "$CACHE_DIR"
|
||||||
|
|
||||||
# Generate thumbnail
|
# Generate thumbnail
|
||||||
generate_thumbnail(){
|
generate_thumbnail() {
|
||||||
local input="$1"
|
local input="$1"
|
||||||
local output="$2"
|
local output="$2"
|
||||||
magick "$input" -thumbnail "${THUMB_WIDTH}x${THUMB_HEIGHT}^" \
|
magick "$input" -thumbnail "${THUMB_WIDTH}x${THUMB_HEIGHT}^" \
|
||||||
-gravity center -extent "${THUMB_WIDTH}x${THUMB_HEIGHT}" "$output"
|
-gravity center -extent "${THUMB_WIDTH}x${THUMB_HEIGHT}" "$output"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate menu with thumbnails
|
# Generate menu with thumbnails
|
||||||
generate_menu(){
|
generate_menu() {
|
||||||
# Find all images and sort naturally
|
# Find all images and sort naturally
|
||||||
while IFS= read -r img; do
|
while IFS= read -r img; do
|
||||||
[[ -f "$img" ]] || continue
|
[[ -f "$img" ]] || continue
|
||||||
ext="${img##*.}"
|
ext="${img##*.}"
|
||||||
thumb="$CACHE_DIR/$(basename "${img%.*}").$ext"
|
thumb="$CACHE_DIR/$(basename "${img%.*}").$ext"
|
||||||
|
|
||||||
# Generate thumbnail if missing or outdated
|
# Generate thumbnail if missing or outdated
|
||||||
if [[ ! -f "$thumb" ]] || [[ "$img" -nt "$thumb" ]]; then
|
if [[ ! -f "$thumb" ]] || [[ "$img" -nt "$thumb" ]]; then
|
||||||
generate_thumbnail "$img" "$thumb"
|
generate_thumbnail "$img" "$thumb"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output for wofi
|
# Output for wofi
|
||||||
echo -en "img:$thumb\x00info:$(basename "$img")\x1f$img\n"
|
echo -en "img:$thumb\x00info:$(basename "$img")\x1f$img\n"
|
||||||
done < <(find "$WALLPAPERS" -maxdepth 1 -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | sort -V)
|
done < <(find "$WALLPAPERS" -maxdepth 1 -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | sort -V)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Run wofi with thumbnails
|
# Run wofi with thumbnails
|
||||||
CHOICE=$(generate_menu | wofi --show dmenu \
|
CHOICE=$(
|
||||||
|
generate_menu | wofi --show dmenu \
|
||||||
--cache-file /dev/null \
|
--cache-file /dev/null \
|
||||||
--define "image-size=${THUMB_WIDTH}x${THUMB_HEIGHT}" \
|
--define "image-size=${THUMB_WIDTH}x${THUMB_HEIGHT}" \
|
||||||
--columns 3 \
|
--columns 3 \
|
||||||
@@ -56,7 +62,7 @@ CHOICE=$(generate_menu | wofi --show dmenu \
|
|||||||
WAL_NAME=$(basename "$CHOICE")
|
WAL_NAME=$(basename "$CHOICE")
|
||||||
SELECTED="$WALLPAPERS/$WAL_NAME"
|
SELECTED="$WALLPAPERS/$WAL_NAME"
|
||||||
|
|
||||||
# Extract THEME name
|
# Extract THEME name (still used for logo mapping)
|
||||||
BASENAME=$(basename "$SELECTED")
|
BASENAME=$(basename "$SELECTED")
|
||||||
THEME="${BASENAME%%_*}"
|
THEME="${BASENAME%%_*}"
|
||||||
|
|
||||||
@@ -66,41 +72,44 @@ LOGO_PATH="$HOME/.config/fastfetch/logo/${THEME,,}_small.png"
|
|||||||
|
|
||||||
# Mapping manual
|
# Mapping manual
|
||||||
if [[ "$THEME" =~ "Endfield" ]]; then
|
if [[ "$THEME" =~ "Endfield" ]]; then
|
||||||
LOGO_PATH="$HOME/.config/fastfetch/logo/john_endfield.png"
|
LOGO_PATH="$HOME/.config/fastfetch/logo/john_endfield.png"
|
||||||
elif [[ "$THEME" =~ "Arknight" ]]; then
|
elif [[ "$THEME" =~ "Arknight" ]]; then
|
||||||
LOGO_PATH="$HOME/.config/fastfetch/logo/john_arknights.png"
|
LOGO_PATH="$HOME/.config/fastfetch/logo/john_arknights.png"
|
||||||
elif [[ "$THEME" =~ "Wuthering" ]]; then
|
elif [[ "$THEME" =~ "Wuthering" ]]; then
|
||||||
LOGO_PATH="$HOME/.config/fastfetch/logo/john_wuthering.png"
|
LOGO_PATH="$HOME/.config/fastfetch/logo/john_wuthering.png"
|
||||||
elif [[ "$THEME" =~ "Genshin" ]]; then
|
elif [[ "$THEME" =~ "Genshin" ]]; then
|
||||||
LOGO_PATH="$HOME/.config/fastfetch/logo/john_genshin.png"
|
LOGO_PATH="$HOME/.config/fastfetch/logo/john_genshin.png"
|
||||||
elif [[ "$THEME" =~ "StarRail" ]]; then
|
elif [[ "$THEME" =~ "StarRail" ]]; then
|
||||||
LOGO_PATH="$HOME/.config/fastfetch/logo/john_starrail.png"
|
LOGO_PATH="$HOME/.config/fastfetch/logo/john_starrail.png"
|
||||||
elif [[ "$THEME" =~ "Zenless" ]]; then
|
elif [[ "$THEME" =~ "Zenless" ]]; then
|
||||||
LOGO_PATH="$HOME/.config/fastfetch/logo/john_zenless.png"
|
LOGO_PATH="$HOME/.config/fastfetch/logo/john_zenless.png"
|
||||||
else
|
else
|
||||||
LOGO_PATH="$HOME/.config/fastfetch/logo/john_wuthering.png"
|
LOGO_PATH="$HOME/.config/fastfetch/logo/john_wuthering.png"
|
||||||
fi
|
|
||||||
|
|
||||||
# Apply theme
|
|
||||||
THEME_FILE="$THEMES/$THEME.json"
|
|
||||||
if [ -f "$THEME_FILE" ]; then
|
|
||||||
"$WAL_BIN" --theme "$THEME_FILE"
|
|
||||||
else
|
|
||||||
"$WAL_BIN" -i "$SELECTED"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update GNOME wallpaper
|
# Update GNOME wallpaper
|
||||||
gsettings set org.gnome.desktop.background picture-uri-dark "file://$SELECTED"
|
gsettings set org.gnome.desktop.background picture-uri-dark "file://$SELECTED"
|
||||||
gsettings set org.gnome.desktop.screensaver picture-uri "file://$SELECTED"
|
gsettings set org.gnome.desktop.screensaver picture-uri "file://$SELECTED"
|
||||||
|
|
||||||
|
# Force fresh pywal colors every time (no cached scheme)
|
||||||
|
rm -rf "$HOME/.cache/wal"/*
|
||||||
|
|
||||||
|
# ALWAYS regenerate pywal colors from selected wallpaper (Option A)
|
||||||
|
"$WAL_BIN" -i "$SELECTED"
|
||||||
|
|
||||||
|
# Reload running WezTerm instances so new wal colors apply
|
||||||
|
if command -v wezterm >/dev/null 2>&1; then
|
||||||
|
wezterm cli reload-configuration >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
# Update fastfetch config
|
# Update fastfetch config
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
jq --arg logo "$LOGO_PATH" \
|
jq --arg logo "$LOGO_PATH" \
|
||||||
--arg wife "$WIFENAME" \
|
--arg wife "$WIFENAME" \
|
||||||
'
|
'
|
||||||
.logo.source = $logo
|
.logo.source = $logo
|
||||||
| (.modules[] | select(.key? == "wife ").format) = $wife
|
| (.modules[] | select(.key? == "wife ").format) = $wife
|
||||||
' "$FASTFETCH_CFG" > "$tmpfile" && mv "$tmpfile" "$FASTFETCH_CFG"
|
' "$FASTFETCH_CFG" >"$tmpfile" && mv "$tmpfile" "$FASTFETCH_CFG"
|
||||||
|
|
||||||
touch "$HOME/.config/fastfetch/.reload_flag"
|
touch "$HOME/.config/fastfetch/.reload_flag"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user