add callback option
This commit is contained in:
parent
70fe7c72ce
commit
d11d8c7f87
5 changed files with 52 additions and 6 deletions
21
wallpaper.go
21
wallpaper.go
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"log"
|
||||
"os/exec"
|
||||
|
||||
"go.i3wm.org/i3"
|
||||
)
|
||||
|
|
@ -17,11 +18,13 @@ func GetWorkspaceWallpaper(workspace string, config Config) string {
|
|||
return file
|
||||
}
|
||||
|
||||
func GetOutputsWallpapers(config Config) ([]string, error) {
|
||||
func GetOutputsWallpapers(config Config) ([]string, []string, error) {
|
||||
files := []string{}
|
||||
screens := []string{}
|
||||
outputs, err := i3.GetOutputs()
|
||||
|
||||
if err != nil {
|
||||
return files, err
|
||||
return files, screens, err
|
||||
}
|
||||
|
||||
for _, output := range outputs {
|
||||
|
|
@ -30,21 +33,29 @@ func GetOutputsWallpapers(config Config) ([]string, error) {
|
|||
|
||||
if file != "" {
|
||||
files = append(files, file)
|
||||
screens = append(screens, output.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return files, nil
|
||||
return files, screens, nil
|
||||
}
|
||||
|
||||
func UpdateWallapers(config Config) {
|
||||
files, err := GetOutputsWallpapers(config)
|
||||
files, screens, err := GetOutputsWallpapers(config)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cmd, err := FehUpdateWallpapers(files)
|
||||
var cmd *exec.Cmd
|
||||
|
||||
if config.Callback == "" {
|
||||
cmd, err = FehUpdateWallpapers(files)
|
||||
} else {
|
||||
cmd, err = CallbackUpdateWallpapers(config.Callback, files, screens)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] cmd=%s error=%s", cmd.String(), err.Error())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue