aboutsummaryrefslogtreecommitdiffstats
path: root/example/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'example/main.go')
-rw-r--r--example/main.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/example/main.go b/example/main.go
index 01b9ee8..4b927da 100644
--- a/example/main.go
+++ b/example/main.go
@@ -2,14 +2,23 @@ package main
import (
"fmt"
+ "io/ioutil"
+ "time"
+
"github.com/getlantern/systray"
"github.com/getlantern/systray/example/icon"
"github.com/skratchdot/open-golang/open"
)
func main() {
+ onExit := func() {
+ fmt.Println("Starting onExit")
+ now := time.Now()
+ ioutil.WriteFile(fmt.Sprintf(`on_exit_%d.txt`, now.UnixNano()), []byte(now.String()), 0644)
+ fmt.Println("Finished onExit")
+ }
// Should be called at the very beginning of main().
- systray.Run(onReady)
+ systray.Run(onReady, onExit)
}
func onReady() {
@@ -19,8 +28,9 @@ func onReady() {
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
go func() {
<-mQuit.ClickedCh
+ fmt.Println("Requesting quit")
systray.Quit()
- fmt.Println("Quit now...")
+ fmt.Println("Finished quitting")
}()
// We can manipulate the systray in other goroutines