From 22b982d9631b5e66ba31efa64c2009097578f879 Mon Sep 17 00:00:00 2001 From: Midov Date: Fri, 2 Oct 2020 17:22:00 +0200 Subject: [PATCH] open reap children --- lib/open/open.go | 10 +++++++++- ui/message-view.go | 1 + ui/room-view.go | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/open/open.go b/lib/open/open.go index 4a92706..935018f 100644 --- a/lib/open/open.go +++ b/lib/open/open.go @@ -20,8 +20,16 @@ package open import ( "os/exec" + "maunium.net/go/gomuks/debug" ) func Open(input string) error { - return exec.Command("xdg-open", input).Start() + cmd := exec.Command("xdg-open", input) + err := cmd.Start() + if err != nil { + debug.Print("xdg-open error:", err) + } else { + go cmd.Wait() + } + return err } diff --git a/ui/message-view.go b/ui/message-view.go index 2410cd5..a2989ff 100644 --- a/ui/message-view.go +++ b/ui/message-view.go @@ -360,6 +360,7 @@ func (view *MessageView) SetSelected(message *messages.UIMessage) { func (view *MessageView) handleMessageClick(message *messages.UIMessage, mod tcell.ModMask) bool { if msg, ok := message.Renderer.(*messages.FileMessage); ok && mod > 0 && !msg.Thumbnail.IsEmpty() { + debug.Print("Opening thumbnail", msg.ThumbnailPath()) open.Open(msg.ThumbnailPath()) // No need to re-render return false diff --git a/ui/room-view.go b/ui/room-view.go index 13ba700..7975106 100644 --- a/ui/room-view.go +++ b/ui/room-view.go @@ -713,6 +713,7 @@ func (view *RoomView) Download(url id.ContentURI, file *attachment.EncryptedFile view.AddServiceMessage(fmt.Sprintf("File downloaded to %s", path)) view.parent.parent.Render() if openFile { + debug.Print("Opening file", path) open.Open(path) } }