chbg: utilize XDG directories
This commit is contained in:
1
.zshrc
1
.zshrc
@@ -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"
|
||||
|
||||
13
bin/chbg
13
bin/chbg
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user