bg slideshow script

This commit is contained in:
andrzej 2024-09-30 19:17:26 +02:00
parent 7c6fc36290
commit aada6a294d
1 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,48 @@
#!/usr/bin/env bash
bgsDirectory="/home/andrzej/bgs/"
while getopts 'p:d:' OPTION; do
case "$OPTION" in
p)
path=${OPTARG}
hyprpaper unload all
;;
d)
duration=${OPTARG}
;;
?)
echo "uh-oh"
;;
esac
done
echo "path: ${path}, duration: ${duration}"
#ARGS $1:directory e.g. chsck
chooseRandom(){
shopt -s nullglob
files=("${bgsDirectory}${1}/"*)
length=$((${#files[@]}))
echo "length: ${length}"
randomIndex=$(($RANDOM % $length))
echo "random index: ${randomIndex}"
##re-roll if the result is a directory
while [[ -d ${files[$randomIndex]} ]]
do
echo "${files[randomIndex]} is a directory!"
randomIndex=$(($RANDOM % $length))
done
image="${files[$randomIndex]}"
echo ${image}
}
while true; do
chooseRandom ${path}
hyprctl hyprpaper preload "${image}"
hyprctl hyprpaper wallpaper ",${image}"
sleep $duration
hyprpaper unload all
done