diff --git a/snowflake.go b/snowflake.go index 88a5528..e7a0076 100644 --- a/snowflake.go +++ b/snowflake.go @@ -62,7 +62,6 @@ func Snowflake() { } else { log.SetOutput(&safelog.LogScrubber{Output: logOutput}) } - go systray.Run(onSnowflakeReady, onSnowflakeExit) go func() { http.Handle("/", http.FileServer(http.Dir(*snowflakeDirectory))) @@ -78,20 +77,20 @@ func Snowflake() { } func onSnowflakeReady() { - systray.SetIcon(icon.Data) - systray.SetTitle("Snowflake Donor") - systray.SetTooltip("You are available to donate a Snowflake snowflakeProxy") - mQuit := systray.AddMenuItem("Stop Snowflake", "Close the application and stop your snowflake.") + if !*snowflake { + return + } + mSnowflakeQuit := systray.AddMenuItem("Stop Snowflake", "Close the application and stop your snowflake.") // Sets the icon of a menu item. Only available on Mac and Windows. - mQuit.SetIcon(icon.Data) + mSnowflakeQuit.SetIcon(icon.Data) runloop := true for runloop { select { - case <-mQuit.ClickedCh: + case <-mSnowflakeQuit.ClickedCh: snowflakeProxy.Stop() runloop = false - + log.Println("Snowflake stopped") } } } diff --git a/systray.go b/systray.go index f9e8f98..9746919 100644 --- a/systray.go +++ b/systray.go @@ -36,6 +36,8 @@ func onReady() { subMenuBottom2 := subMenuTop.AddSubMenuItem("Launch the Tor Browser", "Launch the standard Tor Browser bundle") subMenuBottom3 := subMenuTop.AddSubMenuItem("Launch Hardened Firefox in Clearnet Mode", "Launch the Tor Browser bundle, but without Tor") systray.AddSeparator() + go onSnowflakeReady() + systray.AddSeparator() mQuit := systray.AddMenuItem("Quit", "Quit the whole app") @@ -75,6 +77,7 @@ func onReady() { } func onExit() { + onSnowflakeExit() if shutdown { i2pcontrol.Initialize("127.0.0.1", "7657", "") _, err := i2pcontrol.Authenticate("itoopie")