i3-wallpaper-manager/wallpaper.go
Simon Vieille e229ae1440
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful
ci/woodpecker/tag/build Pipeline was successful
update wallpapers on start
2024-07-31 23:13:59 +02:00

54 lines
981 B
Go

package main
import (
"log"
"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
}
func UpdateWallapers(config Config) {
files, err := GetOutputsWallpapers(config)
if err != nil {
log.Printf("[ERROR] %s", err.Error())
return
}
cmd, err := FehUpdateWallpapers(files)
if err != nil {
log.Printf("[ERROR] cmd=%s error=%s", cmd.String(), err.Error())
} else {
log.Printf("[SUCCESS] cmd=%s", cmd.String())
}
}