Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #192 #193

Merged
merged 1 commit into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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