Fixed some bugs (oops)

This commit is contained in:
Belac Darkstorm
2016-09-22 20:25:26 -05:00
parent fc3411e568
commit 5eeb9cc702
4 changed files with 47 additions and 23 deletions
+7 -1
View File
@@ -2,10 +2,16 @@
LinuxPA is a try to bring a [PortableApps.com](http://portableapps.com) type launcher to Linux.
# How to use
Just double click on an app to launch it! If there are multiple executables, you can either select the specific executable, or if you just double click the app it'll launch the first linux executable, but if one isn't found it launches the first executable in general.
Just double click on an app to launch it! If there are multiple executables, you can either select the specific executable, or if you just double click the app it'll launch the first linux executable (.sh script files have priority), but if one isn't found it launches the first executable in general.
# Apps:
Both of the below places provide linux executables that don't need libs installed on the host system:
[AppImage](https://bintray.com/probono/AppImages)
<s>[Orbital-Apps](https://www.orbital-apps.com/blog/2016/introducing-universal-orbs)</s> (Only works if the Orb-Launcher is installed on the system, for some reason. [Issue](https://github.com/CalebQ42/LinuxPA/issues/3))
# PortableApps.com Compatibility
LinuxPA works will with the PortableApps.com launcher, as it looks for apps in the PortableApps folder and grabs the app's name and icon from where it should be in the PortableApps.com format.
My forum at PortableApps.com can be found [here](http://portableapps.com/node/54998).
# common.sh
common.sh is found in the PortableApps/LinuxPACom folder and is executed before the app. I mainly use it to set environment variables (such as HOME).
+21 -8
View File
@@ -3,7 +3,7 @@ package main
import (
"os"
"os/exec"
"sort"
"strings"
"github.com/nelsam/gxui"
"github.com/nelsam/gxui/math"
@@ -28,7 +28,7 @@ type appExNode struct {
func (a *appExNode) launch() {
if wine {
var cmd *exec.Cmd
if ind := sort.SearchStrings(a.ap.lin, a.ap.ex[a.exInd]); ind == len(a.ap.lin) {
if !contains(a.ap.lin, a.ap.ex[a.exInd]) {
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; wine \""+a.ap.ex[a.exInd]+"\"")
} else {
if comEnbld {
@@ -93,11 +93,10 @@ type appNode struct {
}
func (a *appNode) launch() {
if len(a.ap.ex) == 1 {
if wine {
var cmd *exec.Cmd
if ind := sort.SearchStrings(a.ap.lin, a.ap.ex[0]); ind == len(a.ap.lin) {
if !contains(a.ap.lin, a.ap.ex[0]) {
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; wine \""+a.ap.ex[0]+"\"")
} else {
if comEnbld {
@@ -126,10 +125,17 @@ func (a *appNode) launch() {
if len(a.ap.lin) == 0 {
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; wine \""+a.ap.ex[0]+"\"")
} else {
var ind int
for i, v := range a.ap.lin {
if strings.HasSuffix(v, ".sh") {
ind = i
break
}
}
if comEnbld {
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[0]+"\"")
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[ind]+"\"")
} else {
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[0]+"\"")
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[ind]+"\"")
}
}
cmd.Stdout = os.Stdout
@@ -137,11 +143,18 @@ func (a *appNode) launch() {
cmd.Start()
} else {
if len(a.ap.lin) != 0 {
var ind int
for i, v := range a.ap.lin {
if strings.HasSuffix(v, ".sh") {
ind = i
break
}
}
var cmd *exec.Cmd
if comEnbld {
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[0]+"\"")
cmd = exec.Command("/bin/sh", "-c", ". PortableApps/LinuxPACom/common.sh || exit 1;cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[ind]+"\"")
} else {
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[0]+"\"")
cmd = exec.Command("/bin/sh", "-c", "cd \""+a.ap.dir+"\"; \"./"+a.ap.lin[ind]+"\"")
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
+9
View File
@@ -35,3 +35,12 @@ func appMain(dri gxui.Driver) {
setup()
ui()
}
func contains(arr []string, str string) bool {
for _, v := range arr {
if v == str {
return true
}
}
return false
}
+10 -14
View File
@@ -28,23 +28,17 @@ func setup() {
if _, ok := master[ap.cat]; !ok {
cats = append(cats, ap.cat)
sort.Strings(cats)
if len(ap.lin) != 0 {
}
if len(ap.lin) != 0 {
if _, ok := linmaster[ap.cat]; !ok {
lin = append(lin, ap.cat)
sort.Strings(lin)
}
} else {
if len(ap.lin) != 0 {
ind := sort.SearchStrings(lin, ap.cat)
if ind == len(lin) {
lin = append(lin, ap.cat)
sort.Strings(lin)
}
}
}
master[ap.cat] = append(master[ap.cat], ap)
if len(ap.lin) != 0 {
linmaster[ap.cat] = append(linmaster[ap.cat], ap)
}
master[ap.cat] = append(master[ap.cat], ap)
}
}
}
@@ -84,7 +78,7 @@ func processApp(fold string) (out app) {
btys := make([]byte, 4)
rdr := bufio.NewReader(tmp)
rdr.Read(btys)
if strings.HasPrefix(strings.ToLower(string(btys)), "ELF") || strings.HasPrefix(strings.ToLower(string(btys)), "#!") {
if (strings.Contains(strings.ToLower(string(btys)), "elf") && !strings.HasSuffix(strings.ToLower(v), ".so")) || strings.HasPrefix(strings.ToLower(string(btys)), "#!") {
out.ex = append(out.ex, v)
out.lin = append(out.lin, v)
}
@@ -137,9 +131,11 @@ func getIcon(fold string) gxui.Texture {
}
sort.Strings(pics)
if len(pics) > 1 {
ind := sort.SearchStrings(pics, "appicon_32.png")
if ind == len(pics) {
ind--
var ind int
if !contains(pics, "appicon_32.png") {
ind = len(pics) - 1
} else {
ind = sort.SearchStrings(pics, "appicon_32.png")
}
pic, _ = os.Open(fold + "/App/AppInfo/" + pics[ind])
}