scale images after setting a new wallpaper for improved performance

This commit is contained in:
Daniel Sommer 2023-11-17 13:27:52 +01:00
parent 8e245c0488
commit aa9916ad9a

View file

@ -18,15 +18,23 @@ import (
func Start() {
loggo.Info("starting the image slideshow...", "interval: "+strconv.FormatFloat(config.Interval.Seconds(), 'f', 0, 64)+" seconds")
var sleepTime time.Duration
scaleImages := config.IsResolutionSet()
for {
var data []byte
image := watcher.GetRandomImage()
if config.IsResolutionSet() {
data, error := scale(image)
if scaleImages {
tmp, error := scale(image)
if error != nil {
loggo.Error("encountered an error scaling an image", "image: "+image, error.Error())
continue
}
error = setBackgroundPiped(data)
data = tmp
}
if sleepTime > 0 {
time.Sleep(sleepTime)
}
if scaleImages {
error := setBackgroundPiped(data)
if error != nil {
loggo.Error("encountered an error setting the background via pipe to feh's stdin", error.Error())
}
@ -38,9 +46,6 @@ func Start() {
}
loggo.Info("set new background image", "image: "+image)
}
if sleepTime > 0 {
time.Sleep(sleepTime)
}
sleepTime = time.Until(time.Now().Add(config.Interval))
}
}