From 4dd33ac79ab139e2d70c8b70eaf8d0accc9bf22d Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Wed, 14 Nov 2018 11:54:53 -0600 Subject: [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 --- standalone.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'standalone.go') 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, } -- cgit v1.2.3