From 3629322851e105d9ea40e909566bbafd0eb49aa0 Mon Sep 17 00:00:00 2001 From: velvettear Date: Fri, 17 Nov 2023 14:37:00 +0100 Subject: [PATCH] remember last image to prevent showing the same image twice --- internal/slideshow/slideshow.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/slideshow/slideshow.go b/internal/slideshow/slideshow.go index e6a961e..1ab82e4 100644 --- a/internal/slideshow/slideshow.go +++ b/internal/slideshow/slideshow.go @@ -13,7 +13,8 @@ import ( "git.velvettear.de/velvettear/slideshow/internal/watcher" ) -// internal counter +var previousImage string + // start the slideshow func Start() { loggo.Info("starting the image slideshow...", "interval: "+strconv.FormatFloat(config.Interval.Seconds(), 'f', 0, 64)+" seconds") @@ -22,7 +23,13 @@ func Start() { scaleImages := config.IsResolutionSet() for { var data []byte - image := watcher.GetRandomImage() + var image string + for { + image = watcher.GetRandomImage() + if image != previousImage { + break + } + } if scaleImages { scaleTimestamp := time.Now() tmp, error := scale(image) @@ -34,7 +41,7 @@ func Start() { scaleTime = time.Since(scaleTimestamp) } if sleepTime > 0 { - loggo.Debug("sleeping for '" + strconv.FormatInt(sleepTime.Milliseconds(), 10) + "' ms") + loggo.Debug("sleeping for " + strconv.FormatInt(sleepTime.Milliseconds(), 10) + "ms") time.Sleep(sleepTime) } if scaleImages {