From c48caa5aca800dd62a82ef588d765cdc7507133c Mon Sep 17 00:00:00 2001 From: velvettear Date: Fri, 17 Nov 2023 14:10:00 +0100 Subject: [PATCH] well, now the interval should work as expected --- internal/slideshow/slideshow.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/slideshow/slideshow.go b/internal/slideshow/slideshow.go index 555a7cc..3c249d1 100644 --- a/internal/slideshow/slideshow.go +++ b/internal/slideshow/slideshow.go @@ -18,22 +18,24 @@ import ( func Start() { loggo.Info("starting the image slideshow...", "interval: "+strconv.FormatFloat(config.Interval.Seconds(), 'f', 0, 64)+" seconds") var sleepTime time.Duration + var scaleTime time.Duration scaleImages := config.IsResolutionSet() for { var data []byte image := watcher.GetRandomImage() if scaleImages { + scaleTimestamp := time.Now() tmp, error := scale(image) if error != nil { loggo.Error("encountered an error scaling an image", "image: "+image, error.Error()) continue } data = tmp + scaleTime = time.Since(scaleTimestamp) } if sleepTime > 0 { time.Sleep(sleepTime) } - sleepTime = time.Until(time.Now().Add(config.Interval)) if scaleImages { error := setBackgroundPiped(data) if error != nil { @@ -47,6 +49,7 @@ func Start() { } loggo.Info("set new background image", "image: "+image) } + sleepTime = config.Interval - scaleTime } }