fixed slideshow interval
This commit is contained in:
parent
20dd03dfe1
commit
718bddb4ad
2 changed files with 3 additions and 8 deletions
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -8,7 +8,7 @@
|
|||
"mode": "auto",
|
||||
"program": "${workspaceFolder}/main.go",
|
||||
"env":{
|
||||
"SLIDESHOW_INTERVAL": "10",
|
||||
"SLIDESHOW_INTERVAL": "13",
|
||||
"SLIDESHOW_DIRECTORY": "/home/velvettear/images",
|
||||
"SLIDESHOW_RESOLUTION": "600x1024",
|
||||
"SLIDESHOW_LOGLEVEL": "debug"
|
||||
|
|
|
@ -15,16 +15,11 @@ import (
|
|||
)
|
||||
|
||||
// internal counter
|
||||
var counter int64
|
||||
|
||||
// start the slideshow
|
||||
func Start() {
|
||||
loggo.Info("starting the image slideshow...", "interval: "+strconv.FormatFloat(config.Interval.Seconds(), 'f', 0, 64)+" seconds")
|
||||
for {
|
||||
var sleepTime time.Duration
|
||||
if counter > 0 {
|
||||
sleepTime = time.Until(time.Now().Add(config.Interval))
|
||||
}
|
||||
for {
|
||||
var scaledImage string
|
||||
image := watcher.GetRandomImage()
|
||||
if len(config.Resolution) > 0 {
|
||||
|
@ -38,11 +33,11 @@ func Start() {
|
|||
if sleepTime > 0 {
|
||||
time.Sleep(sleepTime)
|
||||
}
|
||||
sleepTime = time.Until(time.Now().Add(config.Interval))
|
||||
error := setBackground(image)
|
||||
if error != nil {
|
||||
loggo.Error("encountered an error setting the background image", "image: "+image, error.Error())
|
||||
}
|
||||
counter++
|
||||
loggo.Info("set new background image", "image: "+image)
|
||||
if len(scaledImage) > 0 {
|
||||
error = os.Remove(scaledImage)
|
||||
|
|
Loading…
Reference in a new issue