bg slideshow script
This commit is contained in:
parent
7c6fc36290
commit
aada6a294d
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue