54 lines
981 B
Go
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())
|
|
}
|
|
}
|