chbg: utilize XDG directories

This commit is contained in:
2025-12-31 20:06:56 +08:00
parent 8683a7db3b
commit 4cb055fac4
2 changed files with 7 additions and 7 deletions

1
.zshrc
View File

@@ -147,6 +147,7 @@ unset key
# https://unix.stackexchange.com/questions/608842/zshrc-export-gpg-tty-tty-says-not-a-tty
export GPG_TTY=$TTY
alias uvenv='source .venv/bin/activate'
alias noproxy='env -u http_proxy -u https_proxy'
export NVM_DIR="$HOME/.nvm"

View File

@@ -2,22 +2,21 @@
# to change wallpapers both niri workspace and niri tab view
[ -z "$1" ] && { echo "Usage: $0 <image-file>"; exit 1; }
WP_DIR="$HOME/.local/share"
WP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}"
finput=$1
fw=$(magick identify -format "%w\n" $1)
fh=$(magick identify -format "%h\n" $1)
if [[ $((fw)) > 3840 && $((fh)) > 2160 ]]
then
finput="/tmp/${finput##*/}"
read -r fw fh < <(magick identify -format "%w %h" -- "$1")
(( fw > 3840 && fh > 2160 )) && {
finput="${XDG_CACHE_HOME:-$HOME/.cache}/${finput##*/}"
echo "WARNING: image too large, resizing ..."
magick $1 -resize "3840x2160^" $finput
fi
}
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
echo "Done."
swww img $WP_DIR/.wallpaper