i3-wallpaper-manager/wallpaper.go
Simon Vieille 098b04f5a5
Some checks are pending
ci/woodpecker/push/build Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
refactoring: move logic in different files
2024-07-31 12:38:34 +02:00

37 lines
634 B
Go

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
}