well, now the interval should work as expected
This commit is contained in:
parent
ec55a7279b
commit
c48caa5aca
1 changed files with 4 additions and 1 deletions
|
@ -18,22 +18,24 @@ import (
|
||||||
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")
|
||||||
var sleepTime time.Duration
|
var sleepTime time.Duration
|
||||||
|
var scaleTime time.Duration
|
||||||
scaleImages := config.IsResolutionSet()
|
scaleImages := config.IsResolutionSet()
|
||||||
for {
|
for {
|
||||||
var data []byte
|
var data []byte
|
||||||
image := watcher.GetRandomImage()
|
image := watcher.GetRandomImage()
|
||||||
if scaleImages {
|
if scaleImages {
|
||||||
|
scaleTimestamp := time.Now()
|
||||||
tmp, error := scale(image)
|
tmp, error := scale(image)
|
||||||
if error != nil {
|
if error != nil {
|
||||||
loggo.Error("encountered an error scaling an image", "image: "+image, error.Error())
|
loggo.Error("encountered an error scaling an image", "image: "+image, error.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
data = tmp
|
data = tmp
|
||||||
|
scaleTime = time.Since(scaleTimestamp)
|
||||||
}
|
}
|
||||||
if sleepTime > 0 {
|
if sleepTime > 0 {
|
||||||
time.Sleep(sleepTime)
|
time.Sleep(sleepTime)
|
||||||
}
|
}
|
||||||
sleepTime = time.Until(time.Now().Add(config.Interval))
|
|
||||||
if scaleImages {
|
if scaleImages {
|
||||||
error := setBackgroundPiped(data)
|
error := setBackgroundPiped(data)
|
||||||
if error != nil {
|
if error != nil {
|
||||||
|
@ -47,6 +49,7 @@ func Start() {
|
||||||
}
|
}
|
||||||
loggo.Info("set new background image", "image: "+image)
|
loggo.Info("set new background image", "image: "+image)
|
||||||
}
|
}
|
||||||
|
sleepTime = config.Interval - scaleTime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue