fix #1: add cache of latest command to not run wallpaper update when it's already up to date
This commit is contained in:
parent
f8b846018b
commit
3e3f4445a4
4 changed files with 20 additions and 9 deletions
14
wallpaper.go
14
wallpaper.go
|
|
@ -40,7 +40,7 @@ func GetOutputsWallpapers(config Config) ([]string, []string, error) {
|
|||
return files, screens, nil
|
||||
}
|
||||
|
||||
func UpdateWallapers(config Config) {
|
||||
func UpdateWallapers(config Config, lastCommand *string) {
|
||||
files, screens, err := GetOutputsWallpapers(config)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] %s", err.Error())
|
||||
|
|
@ -50,14 +50,22 @@ func UpdateWallapers(config Config) {
|
|||
var cmd *exec.Cmd
|
||||
|
||||
if config.Callback == "" {
|
||||
cmd, err = FehUpdateWallpapers(files)
|
||||
cmd = FehUpdateWallpapers(files)
|
||||
} else {
|
||||
cmd, err = CallbackUpdateWallpapers(config.Callback, files, screens)
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue