remember last image to prevent showing the same image twice

This commit is contained in:
Daniel Sommer 2023-11-17 14:37:00 +01:00
parent 98321903d9
commit 3629322851

View file

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