some ghostty related fix
This commit is contained in:
@@ -72,27 +72,28 @@ touch "$image"
|
||||
# Copy image to local wallpaper directory
|
||||
|
||||
ext=${image##*.}
|
||||
wallpaper_ext="png"
|
||||
random_name=$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 16)
|
||||
current_dir="$HOME/.local/share/wallpaper/current"
|
||||
image_copied="$current_dir/wallpaper-${random_name}.${ext}"
|
||||
wallpaper_image="$current_dir/wallpaper-${random_name}.${wallpaper_ext}"
|
||||
|
||||
mkdir -p "$current_dir" || {
|
||||
echo "Could not create directory $current_dir"
|
||||
exit 1
|
||||
}
|
||||
|
||||
temp_img=$(mktemp --suffix=."$ext") || exit 1
|
||||
temp_img=$(mktemp --suffix=."$wallpaper_ext") || exit 1
|
||||
trap 'rm -f "$temp_img"' EXIT
|
||||
magick "$image" -resize "${screen_width}x${screen_height}^" -gravity center -extent "${screen_width}x${screen_height}" "$temp_img" || {
|
||||
echo "Could not resize and crop image"
|
||||
exit 1
|
||||
}
|
||||
cp "$temp_img" "$image_copied" || exit 1
|
||||
cp "$temp_img" "$wallpaper_image" || exit 1
|
||||
hash="$(md5sum "$image" | awk '{print $1}')-${screen_width}x${screen_height}"
|
||||
|
||||
# Clean up old wallpapers
|
||||
|
||||
find "$current_dir" -type f -name "wallpaper-*" ! -name "$(basename "$image_copied")" -delete
|
||||
find "$current_dir" -type f -name "wallpaper-*" ! -name "$(basename "$wallpaper_image")" -delete
|
||||
|
||||
# Generate blurred wallpaper
|
||||
|
||||
@@ -102,8 +103,8 @@ mkdir -p "$blur_dir" "$blur_cache_dir" || {
|
||||
echo "Could not create cache directory"
|
||||
exit 1
|
||||
}
|
||||
blurred_image="$blur_dir/blurred-${random_name}.$ext"
|
||||
blurred_cache_image="$blur_cache_dir/${hash}.$ext"
|
||||
blurred_image="$blur_dir/blurred-${random_name}.${wallpaper_ext}"
|
||||
blurred_cache_image="$blur_cache_dir/${hash}.${wallpaper_ext}"
|
||||
|
||||
## Time consuming task (magick -blur) in background
|
||||
(
|
||||
@@ -125,7 +126,7 @@ blurred_cache_image="$blur_cache_dir/${hash}.$ext"
|
||||
fi
|
||||
fi
|
||||
|
||||
sigma=$(magick identify -format "%w %h" "$image_copied" | awk -v f=0.01 '{
|
||||
sigma=$(magick identify -format "%w %h" "$wallpaper_image" | awk -v f=0.01 '{
|
||||
m=($1>$2)?$1:$2;
|
||||
s=m*f;
|
||||
if(s<2) s=2;
|
||||
@@ -134,9 +135,9 @@ blurred_cache_image="$blur_cache_dir/${hash}.$ext"
|
||||
}')
|
||||
|
||||
### use a temporary file to avoid incomplete file being used
|
||||
temp_blurred=$(mktemp --suffix=."$ext") || exit 1
|
||||
temp_blurred=$(mktemp --suffix=."$wallpaper_ext") || exit 1
|
||||
trap 'rm -f "${temp_blurred}"' EXIT
|
||||
magick "$image_copied" -blur 0x"$sigma" "$temp_blurred" || {
|
||||
magick "$wallpaper_image" -blur 0x"$sigma" "$temp_blurred" || {
|
||||
echo "Could not create blurred image"
|
||||
exit 1
|
||||
}
|
||||
@@ -163,18 +164,18 @@ blurred_cache_image="$blur_cache_dir/${hash}.$ext"
|
||||
# Apply wallpaper
|
||||
|
||||
if [ "$XDG_CURRENT_DESKTOP" = "Hyprland" ]; then
|
||||
swww img -n background "$image_copied" --transition-type fade --transition-duration 2 >/dev/null 2>/dev/null
|
||||
swww img -n background "$wallpaper_image" --transition-type fade --transition-duration 2 >/dev/null 2>/dev/null
|
||||
|
||||
notify-send -a "change-wallpaper" "Wallpaper Changed" "$image" -i "$image_copied"
|
||||
notify-send -a "change-wallpaper" "Wallpaper Changed" "$image" -i "$wallpaper_image"
|
||||
|
||||
change-colortheme -i "$image_copied" || exit 1
|
||||
change-colortheme -i "$wallpaper_image" || exit 1
|
||||
elif [ "$XDG_CURRENT_DESKTOP" = "niri" ]; then
|
||||
### Handled in wallpaper-daemon
|
||||
# swww img -n background "$image_copied" --transition-type fade --transition-duration 2 > /dev/null 2> /dev/null
|
||||
# swww img -n background "$wallpaper_image" --transition-type fade --transition-duration 2 > /dev/null 2> /dev/null
|
||||
|
||||
notify-send -a "change-wallpaper" "Wallpaper Changed" "$image" -i "$image_copied"
|
||||
notify-send -a "change-wallpaper" "Wallpaper Changed" "$image" -i "$wallpaper_image"
|
||||
|
||||
change-colortheme -i "$image_copied" || exit 1
|
||||
change-colortheme -i "$wallpaper_image" || exit 1
|
||||
else
|
||||
echo "Unsupported desktop environment: $XDG_CURRENT_DESKTOP"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user