diff --git a/config.go b/config.go index ecb0909..e4e27d7 100644 --- a/config.go +++ b/config.go @@ -116,3 +116,9 @@ func SaveConfig() error { return nil } + +func ensureConfigLoaded() { + if config == nil { + LoadConfig() + } +} diff --git a/display.go b/display.go index 9d22c26..a956830 100644 --- a/display.go +++ b/display.go @@ -248,6 +248,8 @@ func startBacklightTickers() { } func init() { + ensureConfigLoaded() + go func() { waitCtrlClientConnected() fmt.Println("setting initial display contents") diff --git a/jiggler.go b/jiggler.go index 06f2b6c..11ce313 100644 --- a/jiggler.go +++ b/jiggler.go @@ -20,6 +20,8 @@ func rpcGetJigglerState() bool { } func init() { + ensureConfigLoaded() + go runJiggler() } diff --git a/network.go b/network.go index 120f9f6..3553015 100644 --- a/network.go +++ b/network.go @@ -190,6 +190,8 @@ func getNTPServersFromDHCPInfo() ([]string, error) { } func init() { + ensureConfigLoaded() + updates := make(chan netlink.LinkUpdate) done := make(chan struct{}) diff --git a/usb.go b/usb.go index 0ff27aa..8f413c7 100644 --- a/usb.go +++ b/usb.go @@ -34,6 +34,8 @@ func mountConfigFS() error { } func init() { + ensureConfigLoaded() + _ = os.MkdirAll(imagesFolder, 0755) udcs := gadget.GetUdcs() if len(udcs) < 1 { @@ -383,6 +385,8 @@ func triggerUSBStateUpdate() { var udc string func init() { + ensureConfigLoaded() + go func() { for { newState := rpcGetUSBState()