Skip to content

Commit

Permalink
Fix #192 (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebQ42 authored Apr 2, 2022
1 parent e9aecb6 commit c2f9a98
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/appimaged/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ func writeDesktopFile(ai AppImage) {
// so that renaming the file in the file manager results in a changed name in the menu
// FIXME: If the thumbnail is not generated here but by another external thumbnailer, it may not be fast enough
time.Sleep(1 * time.Second)
cfg.Section("Desktop Entry").Key("Exec").SetValue(arg0abs + " wrap \"" + ai.Path + "\"") // Resolve to a full path
add := ""
args, err := ai.Args()
if err == nil {
add = " " + strings.Join(args, " ")
}
cfg.Section("Desktop Entry").Key("Exec").SetValue(arg0abs + " wrap \"" + ai.Path + "\"" + add) // Resolve to a full path
cfg.Section("Desktop Entry").Key(ExecLocationKey).SetValue(ai.Path)
cfg.Section("Desktop Entry").Key("TryExec").SetValue(arg0abs) // Resolve to a full path
// For icons, use absolute paths. This way icons start working
Expand Down
22 changes: 22 additions & 0 deletions src/goappimage/appimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
"os"
"os/exec"
Expand Down Expand Up @@ -207,6 +208,27 @@ func (ai AppImage) Icon() (io.ReadCloser, string, error) {
return nil, "", errors.New("Cannot find the AppImage's icon: " + icon)
}

func (ai AppImage) Args() ([]string, error) {
if ai.Desktop == nil {
return nil, errors.New("desktop file wasn't parsed")
}
var exec = ai.Desktop.Section("Desktop Entry").Key("Exec").Value()
fmt.Println("exec:", exec)
if exec == "" {
return nil, errors.New("exec key not present")
}
if strings.HasPrefix(exec, "\"") {
if strings.Contains(exec[1:], "\"") {
exec = exec[1 : strings.Index(exec[1:], "\"")+1]
}
}
spl := strings.Split(exec, " ")
if len(spl) <= 1 {
return make([]string, 0), nil
}
return spl[1:], nil
}

func runCommand(cmd *exec.Cmd) (bytes.Buffer, error) {
var out bytes.Buffer
cmd.Stdout = &out
Expand Down

0 comments on commit c2f9a98

Please sign in to comment.