diff --git a/cmd/fan/fan.go b/cmd/fan/fan.go index e3f0d23..53f8d26 100644 --- a/cmd/fan/fan.go +++ b/cmd/fan/fan.go @@ -20,7 +20,18 @@ const ( func main() { // Load the config file - pfConfig, _ := config.LoadConfig() + pfConfig, configFileProvider := config.LoadConfig() + + // Watch for config changes and re-load config if needed + configFileProvider.Watch(func(event interface{}, err error) { + if err != nil { + log.Printf("Error setting up watch of config : %s", err) + return + } + + // Bail on slideshow if there is a config change so it restarts with updated config + log.Fatalf("Config file changed! Exiting!") + }) log.Print("========================================") pfConfig.Print() diff --git a/cmd/gui/gui.go b/cmd/gui/gui.go index d0c6cf2..9b05cf7 100644 --- a/cmd/gui/gui.go +++ b/cmd/gui/gui.go @@ -38,18 +38,18 @@ func main() { pfConfig.Print() // Watch for config changes and re-load config if needed - // configFileProvider.Watch(func(event interface{}, err error) { - // if err != nil { - // log.Printf("Error setting up watch of config : %s", err) - // return - // } + configFileProvider.Watch(func(event interface{}, err error) { + if err != nil { + log.Printf("Error setting up watch of config : %s", err) + return + } - // // Give the config UI a chance to save and exit clean - // time.Sleep(time.Minute) + // Give the config UI a chance to save and exit clean + time.Sleep(time.Minute) - // // Bail on slideshow if there is a config change so it restarts with updated config - // log.Fatalf("Config file changed! Exiting!") - // }) + // Bail on slideshow if there is a config change so it restarts with updated config + log.Fatalf("Config file changed! Exiting!") + }) // Process command line flags if err := pfConfig.Load(posflag.Provider(f, ".", pfConfig), nil); err != nil { diff --git a/cmd/inotify/inotify.go b/cmd/inotify/inotify.go index fa327ba..d148596 100644 --- a/cmd/inotify/inotify.go +++ b/cmd/inotify/inotify.go @@ -18,7 +18,18 @@ const ( func main() { // Load the config file - pfConfig, _ := config.LoadConfig() + pfConfig, configFileProvider := config.LoadConfig() + + // Watch for config changes and re-load config if needed + configFileProvider.Watch(func(event interface{}, err error) { + if err != nil { + log.Printf("Error setting up watch of config : %s", err) + return + } + + // Bail on slideshow if there is a config change so it restarts with updated config + log.Fatalf("Config file changed! Exiting!") + }) PATH_PICTURES := pfConfig.String(config.CONFIG_KEY_ALBUMS_ROOT)