chbg: make sure resizing output is reachable.
This commit is contained in:
6
bin/chbg
6
bin/chbg
@@ -3,11 +3,13 @@
|
||||
[ -z "$1" ] && { echo "Usage: $0 <image-file>"; exit 1; }
|
||||
|
||||
WP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
TMP_DIR="${XDG_CACHE_HOME:-$HOME/.cache}"
|
||||
finput=$1
|
||||
|
||||
read -r fw fh < <(magick identify -format "%w %h" -- "$1")
|
||||
(( fw > 3840 && fh > 2160 )) && {
|
||||
finput="${XDG_CACHE_HOME:-$HOME/.cache}/${finput##*/}"
|
||||
mkdir -p $TMP_DIR
|
||||
finput="$TMP_DIR/${finput##*/}"
|
||||
echo "WARNING: image too large, resizing ..."
|
||||
magick $1 -resize "3840x2160^" $finput
|
||||
}
|
||||
@@ -16,7 +18,7 @@ echo -n "making blurred version of $finput ... "
|
||||
mkdir -p $WP_DIR
|
||||
cp $finput $WP_DIR/.wallpaper
|
||||
magick $WP_DIR/.wallpaper -filter Gaussian -blur 0x30 $WP_DIR/.wallpaper_blur
|
||||
[[ $finput == "${XDG_CACHE_HOME:-$HOME/.cache}"* ]] && rm -f $finput
|
||||
[[ $finput == $TMP_DIR* ]] && rm -f $finput
|
||||
echo "Done."
|
||||
|
||||
swww img $WP_DIR/.wallpaper
|
||||
|
||||
Reference in New Issue
Block a user