Last active
September 2, 2024 14:24
-
-
Save bitsmanent/204b24de2f0d36ac03f45783391a2786 to your computer and use it in GitHub Desktop.
Rotate wallpapers of a given directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Gist: https://gist.github.com/bitsmanent/204b24de2f0d36ac03f45783391a2786 | |
DELAY=180 | |
DEFAULT_PATH="$HOME/.wallpapers" | |
NEWLINE=" | |
" | |
ARGV0="$(basename "$0")" | |
[ -n "$1" ] && path="$1" || path="." | |
die() { | |
echo $@ | |
exit 1 | |
} | |
getrpic() { | |
path="$1" | |
[ ! -d "$path" ] && exit 1 | |
IFS="$NEWLINE" | |
shuf -n 1 -e "$path"/* | |
} | |
path="$1" | |
[ -z "$path" ] && path="$DEFAULT_PATH" | |
while true; do | |
pic="$(getrpic "$path")" | |
[ -z "$pic" ] && die "$ARGV0: $path: wrong or empty path" | |
tag="$(mimetype -b "$pic" 2>/dev/null |cut -d'/' -f1)" | |
[ "$tag" != "image" ] && die "$ARGV0: $pic: invalid image" | |
feh --bg-max --no-fehbg "$pic" | |
sleep "$DELAY" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this snippet to migrate from pexels.sh:
This should download all images from the collection.