export color palette before setting the background image

This commit is contained in:
Daniel Sommer 2023-11-21 12:47:01 +01:00
parent 65aa2e5e64
commit e00a6e8f6e
2 changed files with 6 additions and 13 deletions

View file

@ -13,7 +13,7 @@ import (
)
// write the base16 color palette to a file
func exportPalette() error {
func exportPalette(image string) error {
if !config.IsPaletteSet() {
return nil
}

View file

@ -13,9 +13,6 @@ import (
"git.velvettear.de/velvettear/slideshow/internal/watcher"
)
// currently set image
var image string
// remember last shown image
var previousImage string
@ -26,6 +23,7 @@ func Start() {
var scaleTime time.Duration
scaleImages := config.IsResolutionSet()
for {
var image string
var data []byte
for {
image = watcher.GetRandomImage()
@ -43,14 +41,14 @@ func Start() {
data = tmp
scaleTime = time.Since(scaleTimestamp)
}
error := exportPalette()
if error != nil {
loggo.Error("encountered an error exporting the color palette for image", "image: "+image, error.Error())
}
if sleepTime > 0 {
loggo.Debug("sleeping for " + strconv.FormatInt(sleepTime.Milliseconds(), 10) + "ms")
time.Sleep(sleepTime)
}
error := exportPalette(image)
if error != nil {
loggo.Error("encountered an error exporting the color palette for image", "image: "+image, error.Error())
}
if scaleImages {
error := setBackgroundPiped(data)
if error != nil {
@ -136,8 +134,3 @@ func setBackgroundPiped(data []byte) error {
}
return nil
}
// get currently shown image
func GetImage() string {
return image
}