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
|
# https://unix.stackexchange.com/questions/608842/zshrc-export-gpg-tty-tty-says-not-a-tty
|
||||||
export GPG_TTY=$TTY
|
export GPG_TTY=$TTY
|
||||||
|
|
||||||
|
alias uvenv='source .venv/bin/activate'
|
||||||
alias noproxy='env -u http_proxy -u https_proxy'
|
alias noproxy='env -u http_proxy -u https_proxy'
|
||||||
|
|
||||||
export NVM_DIR="$HOME/.nvm"
|
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
|
# to change wallpapers both niri workspace and niri tab view
|
||||||
[ -z "$1" ] && { echo "Usage: $0 <image-file>"; exit 1; }
|
[ -z "$1" ] && { echo "Usage: $0 <image-file>"; exit 1; }
|
||||||
|
|
||||||
WP_DIR="$HOME/.local/share"
|
WP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||||
finput=$1
|
finput=$1
|
||||||
|
|
||||||
fw=$(magick identify -format "%w\n" $1)
|
read -r fw fh < <(magick identify -format "%w %h" -- "$1")
|
||||||
fh=$(magick identify -format "%h\n" $1)
|
(( fw > 3840 && fh > 2160 )) && {
|
||||||
if [[ $((fw)) > 3840 && $((fh)) > 2160 ]]
|
finput="${XDG_CACHE_HOME:-$HOME/.cache}/${finput##*/}"
|
||||||
then
|
|
||||||
finput="/tmp/${finput##*/}"
|
|
||||||
echo "WARNING: image too large, resizing ..."
|
echo "WARNING: image too large, resizing ..."
|
||||||
magick $1 -resize "3840x2160^" $finput
|
magick $1 -resize "3840x2160^" $finput
|
||||||
fi
|
}
|
||||||
|
|
||||||
echo -n "making blurred version of $finput ... "
|
echo -n "making blurred version of $finput ... "
|
||||||
mkdir -p $WP_DIR
|
mkdir -p $WP_DIR
|
||||||
cp $finput $WP_DIR/.wallpaper
|
cp $finput $WP_DIR/.wallpaper
|
||||||
magick $WP_DIR/.wallpaper -filter Gaussian -blur 0x30 $WP_DIR/.wallpaper_blur
|
magick $WP_DIR/.wallpaper -filter Gaussian -blur 0x30 $WP_DIR/.wallpaper_blur
|
||||||
|
[[ $finput == "${XDG_CACHE_HOME:-$HOME/.cache}"* ]] && rm -f $finput
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
||||||
swww img $WP_DIR/.wallpaper
|
swww img $WP_DIR/.wallpaper
|
||||||
|
|||||||
Reference in New Issue
Block a user