summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-06-13 13:53:59 +0200
committerRuben Pollan <meskio@sindominio.net>2018-06-20 12:18:17 +0200
commit9f6a017b93569f5abe0ef2aeb22efb05fd0e99a7 (patch)
tree61dc9e974127128546a72b74da0476b87b83a19c
parentfcc7514ec5f1b35068b1033d8ac4278c45043a80 (diff)
[feat] capture SIGINT and close properly
-rw-r--r--systray.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/systray.go b/systray.go
index aea8d04..5b2977e 100644
--- a/systray.go
+++ b/systray.go
@@ -18,6 +18,8 @@ package main
import (
"fmt"
"log"
+ "os"
+ "os/signal"
"time"
"0xacab.org/leap/bitmask-systray/bitmask"
@@ -60,6 +62,9 @@ func (bt bmTray) onExit() {
}
func (bt *bmTray) onReady() {
+ signalCh := make(chan os.Signal, 1)
+ signal.Notify(signalCh, os.Interrupt)
+
systray.SetIcon(icon.Off)
bt.mStatus = systray.AddMenuItem(printer.Sprintf("Checking status..."), "")
@@ -127,8 +132,8 @@ func (bt *bmTray) onReady() {
case <-mQuit.ClickedCh:
systray.Quit()
-
- case <-time.After(time.Minute * 30):
+ case <-signalCh:
+ systray.Quit()
}
}
}()