From aada6a294dda0447adc968be71669e9c21a18772 Mon Sep 17 00:00:00 2001 From: andrzej Date: Mon, 30 Sep 2024 19:17:26 +0200 Subject: [PATCH] bg slideshow script --- scripts/scripts/hyprland-slideshow.sh | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 scripts/scripts/hyprland-slideshow.sh diff --git a/scripts/scripts/hyprland-slideshow.sh b/scripts/scripts/hyprland-slideshow.sh new file mode 100755 index 0000000..d6ea318 --- /dev/null +++ b/scripts/scripts/hyprland-slideshow.sh @@ -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 + + +