From e00a6e8f6e61bb3db29d66d8a04542fd4801168f Mon Sep 17 00:00:00 2001 From: velvettear Date: Tue, 21 Nov 2023 12:47:01 +0100 Subject: [PATCH] export color palette before setting the background image --- internal/slideshow/palette.go | 2 +- internal/slideshow/slideshow.go | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/internal/slideshow/palette.go b/internal/slideshow/palette.go index 4d28cf4..f3a3d86 100644 --- a/internal/slideshow/palette.go +++ b/internal/slideshow/palette.go @@ -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 } diff --git a/internal/slideshow/slideshow.go b/internal/slideshow/slideshow.go index 65b529a..f5495af 100644 --- a/internal/slideshow/slideshow.go +++ b/internal/slideshow/slideshow.go @@ -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 -}