Add CLI flag to only show config UI and skip the slideshow display (so you can config & auto-reload the main piframe ui over ssh and similar
This commit is contained in:
parent
e2bce8d442
commit
712f7c7a45
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
|
@ -8,6 +9,8 @@ import (
|
|||
"github.com/knadh/koanf/parsers/toml"
|
||||
"github.com/knadh/koanf/providers/confmap"
|
||||
"github.com/knadh/koanf/providers/file"
|
||||
"github.com/knadh/koanf/providers/posflag"
|
||||
flag "github.com/spf13/pflag"
|
||||
//"git.kemonine.info/PiFrame/ui"
|
||||
)
|
||||
|
||||
|
@ -29,6 +32,17 @@ const (
|
|||
)
|
||||
|
||||
func main() {
|
||||
// Command line flag handler
|
||||
f := flag.NewFlagSet("config", flag.ContinueOnError)
|
||||
f.Usage = func() {
|
||||
fmt.Println(f.FlagUsages())
|
||||
os.Exit(0)
|
||||
}
|
||||
// Command line flags
|
||||
f.Bool("config-ui-only", false, "Only show the config UI, NOT the slideshow")
|
||||
// Process command line flags into handler
|
||||
f.Parse(os.Args[1:])
|
||||
|
||||
// Main config variable
|
||||
var pfConfig = koanf.New(".")
|
||||
|
||||
|
@ -41,17 +55,23 @@ func main() {
|
|||
CONFIG_KEY_ALBUMS_SELECTED: []string{DEFAULT_ALBUM_SELECTED},
|
||||
}, "."), nil)
|
||||
|
||||
// Bring in /etc/defaults/pf.toml if it exists
|
||||
_, err := os.Stat(CONFIG_FILE_PATH)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
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 {
|
||||
log.Fatalf("Error loading config: %s", err)
|
||||
log.Fatalf("Error loading config : %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
|
Loading…
Reference in a new issue