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 } }