mirror of
https://codeberg.org/frosty/dotfiles.git
synced 2024-09-19 03:37:10 -04:00
bin: simplify wallpaper-set and add some logic to wallpapers-open
This commit is contained in:
parent
b527fcd1a6
commit
4e88fa3acc
|
@ -4,18 +4,13 @@ LOCK_RESOLUTION="1920x1080"
|
||||||
LOCK_QUALITY=70
|
LOCK_QUALITY=70
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
printf '%s: %s\n' "${0##*/}" "$1" >&2
|
printf '%s' "\
|
||||||
|
${0##*/}: $1
|
||||||
|
" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" = "-" ]; then
|
input="$1"
|
||||||
while IFS= read -r line; do
|
|
||||||
input="$line"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
input="$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -f "$input" ] || die "$input: no such file"
|
[ -f "$input" ] || die "$input: no such file"
|
||||||
case "$input" in
|
case "$input" in
|
||||||
|
@ -27,8 +22,6 @@ png | jpg | jpeg) ;;
|
||||||
*) die "$input: unsupported file type" ;;
|
*) die "$input: unsupported file type" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
magick "$1" -resize "$LOCK_RESOLUTION"^ -gravity center -extent "$LOCK_RESOLUTION" -quality "$LOCK_QUALITY" "$XDG_CACHE_HOME/lock.png" &
|
magick "$input" -resize "$LOCK_RESOLUTION"^ -gravity center -extent "$LOCK_RESOLUTION" -quality "$LOCK_QUALITY" "$XDG_CACHE_HOME/lock.png" &
|
||||||
ln -sf "$input" "$XDG_DATA_HOME/wallpaper"
|
ln -sf "$input" "$XDG_DATA_HOME/wallpaper"
|
||||||
xwallpaper --zoom "$XDG_DATA_HOME/wallpaper"
|
xwallpaper --zoom "$XDG_DATA_HOME/wallpaper"
|
||||||
|
|
||||||
notify-send "${0##*/}" "Set wallpaper to <b>${input##*/}</b>."
|
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
find "$HOME/pictures/wallpapers" -type f -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' | shuf | nsxiv -iot | wallpaper-set -
|
set -eu
|
||||||
|
|
||||||
|
IMAGES_DIR="$HOME/pics/wallpapers"
|
||||||
|
|
||||||
|
die() {
|
||||||
|
printf '%s' "\
|
||||||
|
${0##*/}: $1
|
||||||
|
" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -d "$IMAGES_DIR" ] || die "directory not found: $IMAGES_DIR"
|
||||||
|
images_list=$(find "$IMAGES_DIR" -type f -name '*.png' -o -name '*.jpg' -o -name '*.jpeg')
|
||||||
|
[ -n "$images_list" ] || die "no images found"
|
||||||
|
selected_image=$(printf '%s' "$images_list" | shuf | nsxiv -iot)
|
||||||
|
[ -n "$selected_image" ] || exit 0
|
||||||
|
wallpaper-set "$selected_image"
|
||||||
|
|
Loading…
Reference in a new issue