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" "git.velvettear.de/velvettear/slideshow/internal/watcher"
) )
// internal counter var previousImage string
// start the slideshow // start the slideshow
func Start() { func Start() {
loggo.Info("starting the image slideshow...", "interval: "+strconv.FormatFloat(config.Interval.Seconds(), 'f', 0, 64)+" seconds") 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() scaleImages := config.IsResolutionSet()
for { for {
var data []byte var data []byte
image := watcher.GetRandomImage() var image string
for {
image = watcher.GetRandomImage()
if image != previousImage {
break
}
}
if scaleImages { if scaleImages {
scaleTimestamp := time.Now() scaleTimestamp := time.Now()
tmp, error := scale(image) tmp, error := scale(image)
@ -34,7 +41,7 @@ func Start() {
scaleTime = time.Since(scaleTimestamp) scaleTime = time.Since(scaleTimestamp)
} }
if sleepTime > 0 { 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) time.Sleep(sleepTime)
} }
if scaleImages { if scaleImages {