aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msgview/open.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/msgview/open.go')
-rw-r--r--commands/msgview/open.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/commands/msgview/open.go b/commands/msgview/open.go
index 4aa61336..47b43692 100644
--- a/commands/msgview/open.go
+++ b/commands/msgview/open.go
@@ -1,7 +1,6 @@
package msgview
import (
- "errors"
"fmt"
"io"
"io/ioutil"
@@ -28,10 +27,6 @@ func (Open) Complete(aerc *widgets.Aerc, args []string) []string {
}
func (Open) Execute(aerc *widgets.Aerc, args []string) error {
- if len(args) != 1 {
- return errors.New("Usage: open")
- }
-
mv := aerc.SelectedTab().(*widgets.MessageViewer)
p := mv.SelectedMessagePart()
@@ -60,9 +55,22 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error {
return
}
- lib.OpenFile(tmpFile.Name(), func(err error) {
- aerc.PushError(" " + err.Error())
- })
+ xdg := lib.NewXDGOpen(tmpFile.Name())
+ // pass through any arguments the user provided to the underlying handler
+ if len(args) > 1 {
+ xdg.SetArgs(args[1:])
+ }
+ err = xdg.Start()
+ if err != nil {
+ aerc.PushError(err.Error())
+ return
+ }
+ go func() {
+ err := xdg.Wait()
+ if err != nil {
+ aerc.PushError(" " + err.Error())
+ }
+ }()
aerc.PushStatus("Opened", 10*time.Second)
})