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

[feat] discover the path of the svg for the notifications

Try different known paths for the svg file.

- Resolves: #10
parent 218af6e0
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@ const (
donationText = `The RiseupVPN service is expensive to run. Because we don't want to store personal information about you, there is no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month at https://riseup.net/donate-vpn`
missingAuthAgent = `Could not find a polkit authentication agent. Please run one and try again.`
notRunning = `Is bitmaskd running? Start bitmask and try again.`
svgFileName = "riseupvpn.svg"
)
type notificator struct {
......@@ -35,9 +36,8 @@ type notificator struct {
}
func newNotificator(conf *systrayConfig) *notificator {
wd, _ := os.Getwd()
notify := notif.New(notif.Options{
DefaultIcon: path.Join(wd, "riseupvpn.svg"),
DefaultIcon: getSVGPath(),
AppName: "RiseupVPN",
})
n := notificator{notify, conf}
......@@ -63,3 +63,32 @@ func (n *notificator) bitmaskNotRunning() {
func (n *notificator) authAgent() {
n.notify.Push(printer.Sprintf("Missing authentication agent"), printer.Sprintf(missingAuthAgent), "", notif.UR_CRITICAL)
}
func getSVGPath() string {
wd, _ := os.Getwd()
svgPath := path.Join(wd, svgFileName)
if fileExist(svgPath) {
return svgPath
}
svgPath = "/usr/share/riseupvpn/riseupvpn.svg"
if fileExist(svgPath) {
return svgPath
}
gopath := os.Getenv("GOPATH")
if gopath == "" {
gopath = path.Join(os.Getenv("HOME"), "go")
}
svgPath = path.Join(gopath, "src", "0xacab.org", "leap", "bitmask-systray", svgFileName)
if fileExist(svgPath) {
return svgPath
}
return ""
}
func fileExist(filePath string) bool {
_, err := os.Stat(filePath)
return err == nil
}
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