diff --git a/scripts/scripts/bg_slideshow.pid b/scripts/scripts/bg_slideshow.pid new file mode 100644 index 0000000..6cc7f91 --- /dev/null +++ b/scripts/scripts/bg_slideshow.pid @@ -0,0 +1 @@ +11599 diff --git a/scripts/scripts/hyprland-slideshow.sh b/scripts/scripts/hyprland-slideshow.sh index 4a9214d..3222751 100755 --- a/scripts/scripts/hyprland-slideshow.sh +++ b/scripts/scripts/hyprland-slideshow.sh @@ -1,4 +1,24 @@ #!/usr/bin/env bash + +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} @@ -24,10 +44,12 @@ randomIndex=$(($RANDOM % $length)) echo ${image} } + + while true; do chooseRandom ${path} hyprctl hyprpaper preload "${image}" -hyprctl hyprpaper wallpaper ",${image}" +hyprctl hyprpaper wallpaper ",contain:${image}" sleep $duration hyprpaper unload all done diff --git a/scripts/scripts/hyprland-switch-bg.sh b/scripts/scripts/hyprland-switch-bg.sh index 3d6202a..adf05c4 100755 --- a/scripts/scripts/hyprland-switch-bg.sh +++ b/scripts/scripts/hyprland-switch-bg.sh @@ -1,11 +1,18 @@ bgsDirectory="${HOME}/bgs/" +##set working directory to location of this script +cd "$(dirname "$0")" + +##stop slideshow if running +sh ./hyprland-slideshow.sh kill + + preloadImage(){ hyprctl hyprpaper preload "${image}" } setImage() { -hyprctl hyprpaper wallpaper ",${image}" +hyprctl hyprpaper wallpaper ",contain:${image}" } #ARGS $1:directory e.g. chsck