refactoring: move logic in different files
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval

This commit is contained in:
Simon Vieille 2024-07-31 12:38:34 +02:00
commit 098b04f5a5
Signed by: deblan
GPG key ID: 579388D585F70417
5 changed files with 108 additions and 49 deletions

37
wallpaper.go Normal file
View file

@ -0,0 +1,37 @@
package main
import (
"go.i3wm.org/i3"
)
func GetWorkspaceWallpaper(workspace string, config Config) string {
file := config.Default
workspaceFile := config.Workspaces[workspace]
if workspaceFile != "" {
file = workspaceFile
}
return file
}
func GetOutputsWallpapers(config Config) ([]string, error) {
files := []string{}
outputs, err := i3.GetOutputs()
if err != nil {
return files, err
}
for _, output := range outputs {
if output.CurrentWorkspace != "" {
file := GetWorkspaceWallpaper(output.CurrentWorkspace, config)
if file != "" {
files = append(files, file)
}
}
}
return files, nil
}