diff --git a/.vscode/launch.json b/.vscode/launch.json index da4c53c..132cc5d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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" diff --git a/internal/slideshow/slideshow.go b/internal/slideshow/slideshow.go index 6040f51..58669e9 100644 --- a/internal/slideshow/slideshow.go +++ b/internal/slideshow/slideshow.go @@ -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") + var sleepTime time.Duration for { - var sleepTime time.Duration - if counter > 0 { - sleepTime = time.Until(time.Now().Add(config.Interval)) - } 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)