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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -8,6 +9,8 @@ import (
|
||||||
"github.com/knadh/koanf/parsers/toml"
|
"github.com/knadh/koanf/parsers/toml"
|
||||||
"github.com/knadh/koanf/providers/confmap"
|
"github.com/knadh/koanf/providers/confmap"
|
||||||
"github.com/knadh/koanf/providers/file"
|
"github.com/knadh/koanf/providers/file"
|
||||||
|
"github.com/knadh/koanf/providers/posflag"
|
||||||
|
flag "github.com/spf13/pflag"
|
||||||
//"git.kemonine.info/PiFrame/ui"
|
//"git.kemonine.info/PiFrame/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,6 +32,17 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
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
|
// Main config variable
|
||||||
var pfConfig = koanf.New(".")
|
var pfConfig = koanf.New(".")
|
||||||
|
|
||||||
|
@ -41,6 +55,7 @@ func main() {
|
||||||
CONFIG_KEY_ALBUMS_SELECTED: []string{DEFAULT_ALBUM_SELECTED},
|
CONFIG_KEY_ALBUMS_SELECTED: []string{DEFAULT_ALBUM_SELECTED},
|
||||||
}, "."), nil)
|
}, "."), nil)
|
||||||
|
|
||||||
|
// Bring in /etc/defaults/pf.toml if it exists
|
||||||
_, err := os.Stat(CONFIG_FILE_PATH)
|
_, err := os.Stat(CONFIG_FILE_PATH)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
@ -52,6 +67,11 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)
|
// slideshowDuration := pfConfig.Duration(CONFIG_KEY_SLIDESHOW_DURATION)
|
||||||
// hdmiOff := pfConfig.String(CONFIG_KEY_HDMI_OFF)
|
// hdmiOff := pfConfig.String(CONFIG_KEY_HDMI_OFF)
|
||||||
// hdmiOn := pfConfig.String(CONFIG_KEY_HDMI_ON)
|
// hdmiOn := pfConfig.String(CONFIG_KEY_HDMI_ON)
|
||||||
|
|
Loading…
Reference in a new issue