diff options
author | Robin Jarry <robin@jarry.cc> | 2023-03-12 10:55:47 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-03-13 23:35:48 +0100 |
commit | 49f58adda429c54225d79d13bfad7a054ae29db2 (patch) | |
tree | 316fb8eaa0b4c6dd32f610847db58473730ea8d4 /commands/msgview | |
parent | 6ea08564041640a4d3552a9934e4317b1086fa9b (diff) | |
download | aerc-49f58adda429c54225d79d13bfad7a054ae29db2.tar.gz |
openers: add mime type handling for open-link
Provide a way to configure link openers. Based on the URL mime type:
x-scheme-handler/$scheme.
Signed-off-by: Kirill Chibisov <contact@kchibisov.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Diffstat (limited to 'commands/msgview')
-rw-r--r-- | commands/msgview/open-link.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/commands/msgview/open-link.go b/commands/msgview/open-link.go index 257a2fdc..da58b717 100644 --- a/commands/msgview/open-link.go +++ b/commands/msgview/open-link.go @@ -2,6 +2,8 @@ package msgview import ( "errors" + "fmt" + "net/url" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/lib" @@ -30,12 +32,17 @@ func (OpenLink) Complete(aerc *widgets.Aerc, args []string) []string { } func (OpenLink) Execute(aerc *widgets.Aerc, args []string) error { - if len(args) != 2 { - return errors.New("Usage: open-link <url>") + if len(args) < 2 { + return errors.New("Usage: open-link <url> [program [args...]]") } + u, err := url.Parse(args[1]) + if err != nil { + return err + } + mime := fmt.Sprintf("x-scheme-handler/%s", u.Scheme) go func() { defer log.PanicHandler() - if err := lib.XDGOpen(args[1]); err != nil { + if err := lib.XDGOpenMime(args[1], mime, args[2:]); err != nil { aerc.PushError("open-link: " + err.Error()) } }() |