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() { 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
scaleImages := config.IsResolutionSet()
for { for {
var data []byte
image := watcher.GetRandomImage() image := watcher.GetRandomImage()
if config.IsResolutionSet() { if scaleImages {
data, 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
} }
error = setBackgroundPiped(data) data = tmp
}
if sleepTime > 0 {
time.Sleep(sleepTime)
}
if scaleImages {
error := setBackgroundPiped(data)
if error != nil { if error != nil {
loggo.Error("encountered an error setting the background via pipe to feh's stdin", error.Error()) 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) loggo.Info("set new background image", "image: "+image)
} }
if sleepTime > 0 {
time.Sleep(sleepTime)
}
sleepTime = time.Until(time.Now().Add(config.Interval)) sleepTime = time.Until(time.Now().Add(config.Interval))
} }
} }