well, now the interval should work as expected

This commit is contained in:
Daniel Sommer 2023-11-17 14:10:00 +01:00
parent ec55a7279b
commit c48caa5aca

View file

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