diff --git a/cmd/gui/gui.go b/cmd/gui/gui.go index c49bdb4..faaf25c 100644 --- a/cmd/gui/gui.go +++ b/cmd/gui/gui.go @@ -47,7 +47,6 @@ func main() { f.Bool(CLI_FLAG_CONFIG_ONLY, false, "Only show the config UI, NOT the slideshow") cliFlag := f.Lookup(CLI_FLAG_CONFIG_ONLY) if cliFlag != nil { - log.Print("Could not find CLI_FLAG_CONFIG_ONLY") cliFlag.NoOptDefVal = "true" } // Process command line flags into handler @@ -66,31 +65,36 @@ func main() { }, "."), nil) // Bring in /etc/defaults/pf.toml if it exists + configFileProvider := file.Provider(CONFIG_FILE_PATH) _, err := os.Stat(CONFIG_FILE_PATH) if err != nil { if os.IsNotExist(err) { - log.Printf("%s does not exist, USING DEFAULTS", CONFIG_FILE_PATH) + // log.Printf("%s does not exist, USING DEFAULTS", CONFIG_FILE_PATH) } else { - if errConfigFile := pfConfig.Load(file.Provider(CONFIG_FILE_PATH), toml.Parser()); errConfigFile != nil { + if errConfigFile := pfConfig.Load(configFileProvider, toml.Parser()); errConfigFile != nil { log.Fatalf("Error loading config : %s", err) } } } + // 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 + } + + pfConfig.Load(configFileProvider, toml.Parser()) + }) + // Process command line flags if err := pfConfig.Load(posflag.Provider(f, ".", pfConfig), nil); err != nil { log.Fatalf("Error loading command line flags : %v", err) } - // slideshowDuration := pfConfig.Duration(CONFIG_KEY_SLIDESHOW_DURATION) - // hdmiOff := pfConfig.String(CONFIG_KEY_HDMI_OFF) - // hdmiOn := pfConfig.String(CONFIG_KEY_HDMI_ON) - // albumsRoot := pfConfig.String(CONFIG_KEY_ALBUMS_ROOT) - // albumsSelected := pfConfig.Strings(CONFIG_KEY_ALBUMS_SELECTED) - if !pfConfig.Bool(CLI_FLAG_CONFIG_ONLY) { ui.Slideshow() } - //ui.ConfigGui() + ui.ConfigGui() }