Skip to content
Snippets Groups Projects
Verified Commit 9f6a017b authored by meskio's avatar meskio :tent:
Browse files

[feat] capture SIGINT and close properly

parent fcc7514e
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,8 @@ package main ...@@ -18,6 +18,8 @@ package main
import ( import (
"fmt" "fmt"
"log" "log"
"os"
"os/signal"
"time" "time"
"0xacab.org/leap/bitmask-systray/bitmask" "0xacab.org/leap/bitmask-systray/bitmask"
...@@ -60,6 +62,9 @@ func (bt bmTray) onExit() { ...@@ -60,6 +62,9 @@ func (bt bmTray) onExit() {
} }
func (bt *bmTray) onReady() { func (bt *bmTray) onReady() {
signalCh := make(chan os.Signal, 1)
signal.Notify(signalCh, os.Interrupt)
systray.SetIcon(icon.Off) systray.SetIcon(icon.Off)
bt.mStatus = systray.AddMenuItem(printer.Sprintf("Checking status..."), "") bt.mStatus = systray.AddMenuItem(printer.Sprintf("Checking status..."), "")
...@@ -127,8 +132,8 @@ func (bt *bmTray) onReady() { ...@@ -127,8 +132,8 @@ func (bt *bmTray) onReady() {
case <-mQuit.ClickedCh: case <-mQuit.ClickedCh:
systray.Quit() systray.Quit()
case <-signalCh:
case <-time.After(time.Minute * 30): systray.Quit()
} }
} }
}() }()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment