From dc9fc17d93e5186aef835a74c93768c25acd9a08 Mon Sep 17 00:00:00 2001
From: Matteo Suppo <m.suppo@arduino.cc>
Date: Thu, 26 Jul 2018 12:18:47 +0200
Subject: [PATCH] Prevent delays from displaying the trayicon

The trayicon is displayed as soon as possible, in a goroutine.
A select is used to block forever (before it was the trayicon that did
it)
---
 main.go | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/main.go b/main.go
index 3f0614a47..81ac6d860 100755
--- a/main.go
+++ b/main.go
@@ -6,7 +6,6 @@ package main
 import (
 	"encoding/json"
 	"flag"
-	"fmt"
 	"os"
 	"os/user"
 	"path/filepath"
@@ -98,7 +97,8 @@ func main() {
 		os.Exit(0)
 	}
 
-	fmt.Println(*hibernate)
+	// Launch systray
+	go setupSysTray()
 
 	if *hibernate == false {
 		// autoextract self
@@ -288,7 +288,9 @@ func main() {
 			}
 		}()
 	}
-	setupSysTray()
+
+	// Block forever until the application is shut down
+	select {}
 }
 
 var homeTemplate = template.Must(template.New("home").Parse(homeTemplateHtml))