aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/msg/unsubscribe.go2
-rw-r--r--commands/msgview/open.go5
-rw-r--r--lib/open.go15
-rw-r--r--lib/open_darwin.go15
4 files changed, 29 insertions, 8 deletions
diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go
index 1a2dd373..dec90d5e 100644
--- a/commands/msg/unsubscribe.go
+++ b/commands/msg/unsubscribe.go
@@ -115,6 +115,6 @@ func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error {
}
func unsubscribeHTTP(u *url.URL) error {
- go lib.OpenFile(u.String())
+ lib.OpenFile(u.String(), nil)
return nil
}
diff --git a/commands/msgview/open.go b/commands/msgview/open.go
index f708b2dd..4aa61336 100644
--- a/commands/msgview/open.go
+++ b/commands/msgview/open.go
@@ -60,10 +60,9 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error {
return
}
- err = lib.OpenFile(tmpFile.Name())
- if err != nil {
+ lib.OpenFile(tmpFile.Name(), func(err error) {
aerc.PushError(" " + err.Error())
- }
+ })
aerc.PushStatus("Opened", 10*time.Second)
})
diff --git a/lib/open.go b/lib/open.go
index ad6533e1..ebcf8780 100644
--- a/lib/open.go
+++ b/lib/open.go
@@ -6,7 +6,18 @@ import (
"os/exec"
)
-func OpenFile(filename string) error {
+func OpenFile(filename string, onErr func(error)) {
cmd := exec.Command("xdg-open", filename)
- return cmd.Run()
+ err := cmd.Start()
+ if err != nil && onErr != nil {
+ onErr(err)
+ return
+ }
+
+ go func() {
+ err := cmd.Wait()
+ if err != nil && onErr != nil {
+ onErr(err)
+ }
+ }()
}
diff --git a/lib/open_darwin.go b/lib/open_darwin.go
index 0ffd9a16..d98c8988 100644
--- a/lib/open_darwin.go
+++ b/lib/open_darwin.go
@@ -4,7 +4,18 @@ import (
"os/exec"
)
-func OpenFile(filename string) error {
+func OpenFile(filename string, onErr func(error)) {
cmd := exec.Command("open", filename)
- return cmd.Run()
+ err := cmd.Start()
+ if err != nil && onErr != nil {
+ onErr(err)
+ return
+ }
+
+ go func() {
+ err := cmd.Wait()
+ if err != nil && onErr != nil {
+ onErr(err)
+ }
+ }()
}