package main import ( "log" "os/exec" "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, []string, error) { files := []string{} screens := []string{} outputs, err := i3.GetOutputs() if err != nil { return files, screens, err } for _, output := range outputs { if output.CurrentWorkspace != "" { file := GetWorkspaceWallpaper(output.CurrentWorkspace, config) if file != "" { files = append(files, file) screens = append(screens, output.Name) } } } return files, screens, nil } func UpdateWallapers(config Config, lastCommand *string) { files, screens, err := GetOutputsWallpapers(config) if err != nil { log.Printf("[ERROR] %s", err.Error()) return } var cmd *exec.Cmd if config.Callback == "" { cmd = FehUpdateWallpapers(files) } else { cmd = CallbackUpdateWallpapers(config.Callback, files, screens) } if cmd.String() == *lastCommand { log.Printf("[INFO] wallapaper(s) already up to date") return } err = cmd.Run() if err != nil { log.Printf("[ERROR] cmd=%s error=%s", cmd.String(), err.Error()) } else { log.Printf("[SUCCESS] cmd=%s", cmd.String()) *lastCommand = cmd.String() } }