From 7be59efa6f096c50095e238978dfebb9666dd051 Mon Sep 17 00:00:00 2001 From: Tacocake Date: Fri, 8 Nov 2024 12:29:31 -0500 Subject: [PATCH 1/3] fix: only try to get absolute path if the string indicates it is relative --- beeep.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beeep.go b/beeep.go index b0e66d4..3896e29 100644 --- a/beeep.go +++ b/beeep.go @@ -5,6 +5,7 @@ import ( "errors" "path/filepath" "runtime" + "strings" ) var ( @@ -16,7 +17,7 @@ func pathAbs(path string) string { var err error var abs string - if path != "" { + if path != "" && strings.ContainsAny(path, "/\\.") { abs, err = filepath.Abs(path) if err != nil { abs = path From 76bbc7acfd9cc085fff27602eb045f0c842b6d01 Mon Sep 17 00:00:00 2001 From: Tacocake Date: Fri, 8 Nov 2024 12:53:08 -0500 Subject: [PATCH 2/3] fix: reapply patch but just for unix notifications --- beeep.go | 3 +-- notify_unix.go | 14 +++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/beeep.go b/beeep.go index 3896e29..b0e66d4 100644 --- a/beeep.go +++ b/beeep.go @@ -5,7 +5,6 @@ import ( "errors" "path/filepath" "runtime" - "strings" ) var ( @@ -17,7 +16,7 @@ func pathAbs(path string) string { var err error var abs string - if path != "" && strings.ContainsAny(path, "/\\.") { + if path != "" { abs, err = filepath.Abs(path) if err != nil { abs = path diff --git a/notify_unix.go b/notify_unix.go index 04dffd6..b4eae39 100644 --- a/notify_unix.go +++ b/notify_unix.go @@ -10,11 +10,23 @@ import ( "github.com/godbus/dbus/v5" ) +func isAppIconRelative(appIcon string) bool { + for _, char := range appIcon { + if char == '\\' || char == '.' || char == '/' { + println(char) + return true + } + } + return false +} + // Notify sends desktop notification. // // On Linux it tries to send notification via D-Bus and it will fallback to `notify-send` binary. func Notify(title, message, appIcon string) error { - appIcon = pathAbs(appIcon) + if isAppIconRelative(appIcon) { + appIcon = pathAbs(appIcon) + } cmd := func() error { send, err := exec.LookPath("sw-notify-send") From 1920cfc0dd2cbe49a76eb9fde3b19bdb9d2cf3e0 Mon Sep 17 00:00:00 2001 From: Tacocake Date: Fri, 8 Nov 2024 12:53:33 -0500 Subject: [PATCH 3/3] chore: remove useless print --- notify_unix.go | 1 - 1 file changed, 1 deletion(-) diff --git a/notify_unix.go b/notify_unix.go index b4eae39..108534a 100644 --- a/notify_unix.go +++ b/notify_unix.go @@ -13,7 +13,6 @@ import ( func isAppIconRelative(appIcon string) bool { for _, char := range appIcon { if char == '\\' || char == '.' || char == '/' { - println(char) return true } }