From 25f7f2a6b72d99bdcda572234031a2c4f6967703 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 27 Jan 2025 00:10:18 +0000 Subject: [PATCH] [autopape.sh]: Add shuffle -s flag --- src/autopape.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/autopape.sh b/src/autopape.sh index e0015ac..6f832bc 100755 --- a/src/autopape.sh +++ b/src/autopape.sh @@ -10,12 +10,13 @@ Usage: autopape.sh [OPTIONS]... [ARGUMENTS]... Iterate over the files in a directory and set them as the desktop wallpaper at a regular interval. Options: -c Specify the command that should be used to set the wallpaper. Defaults to 'feh --bg-fill' - -h Print this help message -i Specify the interval between wallpaper changes. Defaults to '1m' + -h Print this help message + -s Shuffle the files in the directory for each iteration EOF } -while getopts 'c:i:h' flag; do +while getopts 'c:i:h:s' flag; do case "${flag}" in c) command="${OPTARG}";; @@ -27,6 +28,9 @@ while getopts 'c:i:h' flag; do usage exit 0;; + s) + files=$(find . -maxdepth 1 -type f | shuf);; + *) usage exit 1;; @@ -35,7 +39,11 @@ done while [ true ] do - for img in * + if [ -z $files ];then + files-$(find . -maxdepth 1 -type f) + fi + + for img in $files do eval "$command '$img'" sleep "$interval"