summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-03-19 08:38:18 +0100
committerRuben Pollan <meskio@sindominio.net>2018-03-20 10:29:26 +0100
commite7ab6ad504b0a7524766717c9b68c2ac332f07f1 (patch)
tree4745266ce68ac64daec66c7e8b8d5036119f22b5 /main.go
parent5dd03466c628b63ce4f746997e4fb77f0f2b960f (diff)
[feat] only one systray can be in execution
Create a systray.pid file to check if another systray is in execution and only one systray is allowed to be running. - Resolves: #17
Diffstat (limited to 'main.go')
-rw-r--r--main.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/main.go b/main.go
index 95f8ff4..0e067ca 100644
--- a/main.go
+++ b/main.go
@@ -30,6 +30,12 @@ const (
var printer *message.Printer
func main() {
+ err := acquirePID()
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer releasePID()
+
conf := parseConfig()
initPrinter()
@@ -37,22 +43,28 @@ func main() {
b, err := bitmask.Init()
if err != nil {
- log.Fatal(err)
+ log.Print(err)
+ return
}
defer b.Close()
- checkAndInstallHelpers(b, notify)
+ err = checkAndInstallHelpers(b, notify)
+ if err != nil {
+ log.Printf("Is bitmask running? %v", err)
+ return
+ }
+
run(b, conf)
}
-func checkAndInstallHelpers(b *bitmask.Bitmask, notify *notificator) {
+func checkAndInstallHelpers(b *bitmask.Bitmask, notify *notificator) error {
helpers, priviledge, err := b.VPNCheck()
if (err != nil && err.Error() == "nopolkit") || (err == nil && !priviledge) {
log.Printf("No polkit found")
notify.authAgent()
} else if err != nil {
notify.bitmaskNotRunning()
- log.Fatal("Is bitmask running? ", err)
+ return err
}
if !helpers {
@@ -61,6 +73,7 @@ func checkAndInstallHelpers(b *bitmask.Bitmask, notify *notificator) {
log.Println("Error installing helpers: ", err)
}
}
+ return nil
}
func initPrinter() {