remember last image to prevent showing the same image twice
This commit is contained in:
parent
98321903d9
commit
3629322851
1 changed files with 10 additions and 3 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue