open reap children

This commit is contained in:
Midov 2020-10-02 17:22:00 +02:00
parent 180ecc36cc
commit 22b982d963
3 changed files with 11 additions and 1 deletions

View File

@ -20,8 +20,16 @@ package open
import ( import (
"os/exec" "os/exec"
"maunium.net/go/gomuks/debug"
) )
func Open(input string) error { 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
} }

View File

@ -360,6 +360,7 @@ func (view *MessageView) SetSelected(message *messages.UIMessage) {
func (view *MessageView) handleMessageClick(message *messages.UIMessage, mod tcell.ModMask) bool { func (view *MessageView) handleMessageClick(message *messages.UIMessage, mod tcell.ModMask) bool {
if msg, ok := message.Renderer.(*messages.FileMessage); ok && mod > 0 && !msg.Thumbnail.IsEmpty() { if msg, ok := message.Renderer.(*messages.FileMessage); ok && mod > 0 && !msg.Thumbnail.IsEmpty() {
debug.Print("Opening thumbnail", msg.ThumbnailPath())
open.Open(msg.ThumbnailPath()) open.Open(msg.ThumbnailPath())
// No need to re-render // No need to re-render
return false return false

View File

@ -713,6 +713,7 @@ func (view *RoomView) Download(url id.ContentURI, file *attachment.EncryptedFile
view.AddServiceMessage(fmt.Sprintf("File downloaded to %s", path)) view.AddServiceMessage(fmt.Sprintf("File downloaded to %s", path))
view.parent.parent.Render() view.parent.parent.Render()
if openFile { if openFile {
debug.Print("Opening file", path)
open.Open(path) open.Open(path)
} }
} }