diff --git a/internal/appherder/launch.go b/internal/appherder/launch.go new file mode 100644 index 0000000..8480ad0 --- /dev/null +++ b/internal/appherder/launch.go @@ -0,0 +1,22 @@ +package appherder + +import ( + "fmt" + "os/exec" +) + +// Launch starts the installed AppImage for appid and returns immediately. +func (a App) Launch(appid string) error { + path, err := findAppImagePath(a.appimagesDir, appid) + if err != nil { + return err + } + if path == "" { + return fmt.Errorf("appimage %s is not installed", appid) + } + cmd := exec.Command(path) + if err := cmd.Start(); err != nil { + return fmt.Errorf("launch %s: %w", appid, err) + } + return cmd.Process.Release() +} diff --git a/internal/appherder/launch_test.go b/internal/appherder/launch_test.go new file mode 100644 index 0000000..6d97ec4 --- /dev/null +++ b/internal/appherder/launch_test.go @@ -0,0 +1,10 @@ +package appherder + +import "testing" + +func TestLaunchMissingApp(t *testing.T) { + a, _ := newTestApp(t) + if err := a.Launch("missing"); err == nil { + t.Fatal("Launch missing app succeeded, want error") + } +} diff --git a/internal/appherder/list.go b/internal/appherder/list.go index b25de84..66804f1 100644 --- a/internal/appherder/list.go +++ b/internal/appherder/list.go @@ -14,6 +14,7 @@ type AppInfo struct { Name string // desktop Name= field, falls back to filename Icon string // desktop Icon= field, usually appherder's installed icon path Filename string // basename of the AppImage in ~/AppImages, "" when missing + Path string // full path to the AppImage in ~/AppImages, "" when missing Version string // desktop X-AppImage-Version= Size int64 Source string // update source kind, "none" when no info @@ -57,6 +58,7 @@ func gatherAppInfo(appsDir, appimagesDir, appid string) AppInfo { var signed bool if path, err := findAppImagePath(appimagesDir, appid); err == nil && path != "" { + info.Path = path info.Filename = filepath.Base(path) if stat, err := os.Stat(path); err == nil { info.Size = stat.Size()