diff options
author | Andrew Jeffery <dev@jeffas.io> | 2020-07-06 20:14:15 +0100 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-07-08 09:07:43 +0200 |
commit | fda3f43e7c5e5a175a01dd3e5b8637b1ecb30c51 (patch) | |
tree | 8f6f15424a9e5711ade8b9ef66679cdf5aeb4779 /lib/open_darwin.go | |
parent | 3e6189f243c8d0717979da1a1a18e46996f6a2ef (diff) | |
download | aerc-fda3f43e7c5e5a175a01dd3e5b8637b1ecb30c51.tar.gz |
Allow open to be asynchronous
This stops the ui being blocked while the resource is opened. The wait ensures that resources are reclaimed when the process finishes while aerc is still running.
Diffstat (limited to 'lib/open_darwin.go')
-rw-r--r-- | lib/open_darwin.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/open_darwin.go b/lib/open_darwin.go index 0ffd9a1..d98c898 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) + } + }() } |