summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-11-14 11:54:53 -0600
committerRuben Pollan <meskio@sindominio.net>2018-11-14 13:35:10 -0600
commit4dd33ac79ab139e2d70c8b70eaf8d0accc9bf22d (patch)
tree3b59a435fa6b0ebce31f98962c2afa01e80e5ad0
parent66134bc4a2f161f9909e0e71d8e3dfbc5ea97d35 (diff)
[bug] add the right executable to the snap autostart
In case of SNAP environment we need to execute the /snap/bin/app.launcher and not os.Args[0]. - Resolves: #82
-rw-r--r--standalone.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/standalone.go b/standalone.go
index ebcc040..41b3c94 100644
--- a/standalone.go
+++ b/standalone.go
@@ -18,8 +18,10 @@ package main
import (
"errors"
+ "fmt"
"log"
"os"
+ "regexp"
"0xacab.org/leap/bitmask-systray/bitmask"
standalone "0xacab.org/leap/bitmask-systray/standalone"
@@ -40,9 +42,22 @@ func initBitmask() (bitmask.Bitmask, error) {
}
func newAutostart(appName string, iconPath string) autostart {
+ exec := os.Args
+ if os.Getenv("SNAP") != "" {
+ re := regexp.MustCompile("/snap/([^/]*)/")
+ match := re.FindStringSubmatch(os.Args[0])
+ if len(match) > 1 {
+ snapName := match[1]
+ exec = []string{fmt.Sprintf("/snap/bin/%s.launcher", snapName)}
+ } else {
+ log.Printf("Snap binary has unknown path: %v", os.Args[0])
+ }
+ }
+
+
return &pmautostart.App{
Name: appName,
- Exec: os.Args,
+ Exec: exec,
DisplayName: appName,
Icon: iconPath,
}