62 lines
1.0 KiB
Bash
Executable File
62 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
##set working directory to location of this script
|
|
cd "$(dirname "$0")"
|
|
|
|
PIDFILE=bg_slideshow.pid
|
|
remove_pidfile()
|
|
{
|
|
rm -f "$PIDFILE"
|
|
}
|
|
|
|
if [ -f "$PIDFILE" ]; then
|
|
kill -9 "$(cat $PIDFILE)"
|
|
fi
|
|
|
|
if [[ ${1} == kill ]]; then
|
|
echo "killing myslef, byeeee"
|
|
exit
|
|
fi
|
|
|
|
|
|
echo $$ > "$PIDFILE"
|
|
|
|
|
|
bgsDirectory="/home/andrzej/bgs/"
|
|
path=${1}
|
|
duration=${2}
|
|
|
|
|
|
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 ",contain:${image}"
|
|
sleep $duration
|
|
hyprpaper unload all
|
|
done
|
|
|
|
|
|
|