Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e4e5adaf13 | |||
| 7a2ebd533e | |||
| 2f0ca5418c | |||
| ce9d4aed23 | |||
| 712a5ab33d | |||
| 6723f933b4 | |||
| 016fc35745 | |||
| ba5e3510ec | |||
| 7e2d7ee14b | |||
| b20de4f1d6 | |||
| d2e91baa6b | |||
| a0f22e480b | |||
| 57f921c2cb | |||
| 55f897db46 | |||
| 3d9583281e | |||
| ec4d66f6b2 | |||
| c442ef5688 | |||
| 78d3723bf4 | |||
| 828b9f4cda | |||
| be64aa083f | |||
| 3111705cae | |||
| 868ae8f700 |
@@ -1,36 +1,51 @@
|
||||
# LinuxPA
|
||||
|
||||
LinuxPA is a try to bring a [PortableApps.com](http://portableapps.com) type launcher to Linux.
|
||||
|
||||
# How to use
|
||||
## 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 it finds. .sh script files have priority over other executable files.
|
||||
|
||||
# Apps:
|
||||
## Apps
|
||||
|
||||
The below place provides linux executables that don't need libs installed on the host system:
|
||||
[AppImage](https://bintray.com/probono/AppImages)
|
||||
[https://appimage.github.io/](https://appimage.github.io/)
|
||||
|
||||
## PortableApps.com Compatibility
|
||||
|
||||
# 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). You can create and edit the common.sh from settings
|
||||
## 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). You can create and edit the common.sh from settings.
|
||||
|
||||
## Simple App Setup
|
||||
|
||||
# Simple App Setup
|
||||
Because apps aren't natively formated in the PortableApps.com format, LinuxPA will look in the root directory for a AppInfo.ini (for basic info such as category and name) and appicon.png. If they aren't found, it looks where the appicon_\*.png and AppInfo.ini is in PortableApps format. You can set what the AppInfo.ini and appicon.png are from LinuxPA.
|
||||
|
||||
# AppImage Support
|
||||
[AppImage Website](http://appimage.org)
|
||||
Right now AppImages are simply supported via the native linux executable support, and you can download AppImages. (Woo)
|
||||
## AppImage Support
|
||||
|
||||
[AppImage Website](http://appimage.org)
|
||||
I'm looking into improving AppImage support. As of 2.1.5.0 IF `unsquashfs` is in $PATH then some advanced AppImage support is available and it will automagically get the name and possibly the icon of it. I'm looking into better support, but it might be a while.
|
||||
|
||||
## USB mount
|
||||
|
||||
# USB mount
|
||||
Unfortunately Linux, by default, doesn't support running executables off of FAT formated flash drives, requiring you to mount your drive with special mount arguments or format in a linux friendly format (such as EXT4). I personally use the arguments `exec,noauto,nodev,nosuid,umask=0000`
|
||||
|
||||
# Screenshots
|
||||
## Screenshots
|
||||
|
||||
Photos are found [Here](https://goo.gl/photos/VtBUL6DyZTMidj5n6). The screenshots are with the adapta gtk theme
|
||||
|
||||
# TODO (Might be in order)
|
||||
1. MAKE IT BETTER
|
||||
1. Ask if you want to update / manual update check
|
||||
1. Show change log on update
|
||||
1. Better appimage support in general
|
||||
1. Check if all apps are closed when it closes and ask if you want to force stop the apps
|
||||
## TODO (Might be in order)
|
||||
|
||||
1. MAKE IT BETTER
|
||||
1. Integrate [goappimage](https://github.com/probonod/go-appimage) library for better AppImage integration.
|
||||
1. Try to `chmod +x` executables if they don't have the permission
|
||||
1. Manual update check
|
||||
1. Better AppImage integrations (Specifically updating and better appimage downloading)
|
||||
1. Get information (such as name and icon) directly from an appimage
|
||||
1. Better appimage downloading (probably based around [AppImageHub](https://appimage.github.io/apps/))
|
||||
1. Sandboxing support
|
||||
1. Might be possible by packaging as an AppImage and providing Firejail, or simply just downloading it (like with Wine)
|
||||
1. Check if all apps are closed when it closes and ask if you want to force stop the apps
|
||||
|
||||
@@ -20,11 +20,13 @@ type app struct {
|
||||
icon *gdk.Pixbuf
|
||||
dir string
|
||||
ini *os.File
|
||||
wine bool
|
||||
}
|
||||
|
||||
func (a *app) getTreeIter(store *gtk.TreeStore) *gtk.TreeIter {
|
||||
it := store.Append(nil)
|
||||
store.SetValue(it, 0, a.icon)
|
||||
scaled, _ := a.icon.ScaleSimple(32, 32, gdk.INTERP_HYPER)
|
||||
store.SetValue(it, 0, scaled)
|
||||
if portableHide {
|
||||
store.SetValue(it, 1, strings.TrimSuffix(a.name, "Portable"))
|
||||
} else {
|
||||
@@ -217,7 +219,7 @@ func (a *app) edit(parent *gtk.Window, reload func()) {
|
||||
fil.Close()
|
||||
})
|
||||
resp := fil.Run()
|
||||
if resp == int(gtk.RESPONSE_ACCEPT) {
|
||||
if resp == gtk.RESPONSE_ACCEPT {
|
||||
filename := fil.GetFilename()
|
||||
_, err := os.Open(filename)
|
||||
if err != nil {
|
||||
@@ -242,7 +244,11 @@ func (a *app) edit(parent *gtk.Window, reload func()) {
|
||||
nameTxt.SetHExpand(true)
|
||||
nameTxt.SetVExpand(false)
|
||||
nameTxt.SetBorderWindowSize(gtk.TEXT_WINDOW_BOTTOM, 5)
|
||||
txtBuf.SetText(tmp.name)
|
||||
nameShow := tmp.name
|
||||
if tmp.wine {
|
||||
nameShow = strings.TrimSuffix(nameShow, " (Wine)")
|
||||
}
|
||||
txtBuf.SetText(nameShow)
|
||||
vScrollName, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
||||
hScrollName, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
||||
nameScr, _ := gtk.ScrolledWindowNew(hScrollName, vScrollName)
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package appimg
|
||||
|
||||
import "reflect"
|
||||
|
||||
func convert(in string) (out []tag) {
|
||||
for i := 0; i < len(in); i++ {
|
||||
v := in[i]
|
||||
if v == '<' {
|
||||
for j := i; j < len(in); j++ {
|
||||
val := in[j]
|
||||
if val == '>' {
|
||||
var tmp tag
|
||||
tmp.process(in[i+1 : j+1])
|
||||
if !tmp.end && tmp.typ == "a" {
|
||||
tmp.index[0] = i
|
||||
tmp.index[1] = j
|
||||
nd := fndend(tmp, in[j+1:])
|
||||
if !reflect.DeepEqual(nd, tag{}) {
|
||||
tmp.Meat = in[j+1 : nd.index[0]]
|
||||
out = append(out, tmp)
|
||||
str := in[tmp.index[1]:nd.index[0]]
|
||||
in = in[:i] + str + in[nd.index[1]+1:]
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func fndend(fnt tag, area string) tag {
|
||||
var count int
|
||||
for i, v := range area {
|
||||
if v == '<' {
|
||||
for j, val := range area[i:] {
|
||||
if val == '>' {
|
||||
var tmp tag
|
||||
tmp.process(area[i+1 : i+j+1])
|
||||
if tmp.typ == fnt.typ {
|
||||
if tmp.end {
|
||||
if count == 0 {
|
||||
tmp.index[0] = fnt.index[1] + 1 + i
|
||||
tmp.index[1] = fnt.index[1] + j + i + 1
|
||||
return tmp
|
||||
}
|
||||
count--
|
||||
break
|
||||
} else {
|
||||
count++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tag{}
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
package appimg
|
||||
|
||||
import "strings"
|
||||
|
||||
type tag struct {
|
||||
typ string
|
||||
end bool
|
||||
params map[string]string
|
||||
index [2]int
|
||||
Meat string
|
||||
}
|
||||
|
||||
func (t *tag) value(param string) string {
|
||||
return t.params[param]
|
||||
}
|
||||
|
||||
func (t *tag) setValue(param, value string) {
|
||||
if t.params == nil {
|
||||
t.params = make(map[string]string)
|
||||
}
|
||||
t.params[strings.TrimSpace(strings.ToLower(param))] = strings.TrimSpace(value)
|
||||
}
|
||||
|
||||
func (t *tag) process(bbtag string) {
|
||||
if strings.HasPrefix(bbtag, "/") {
|
||||
t.end = true
|
||||
t.typ = strings.ToLower(strings.TrimPrefix(bbtag[:len(bbtag)-1], "/"))
|
||||
return
|
||||
}
|
||||
for i, v := range bbtag {
|
||||
if v == '=' || v == ' ' || v == '>' {
|
||||
t.typ = strings.ToLower(bbtag[:i])
|
||||
switch v {
|
||||
case '=':
|
||||
if qt := bbtag[i+1]; qt == '\'' || qt == '"' {
|
||||
for j := i + 2; j < len(bbtag); j++ {
|
||||
if bbtag[j] == qt {
|
||||
t.setValue("starting", bbtag[i+2:j])
|
||||
bbtag = bbtag[j+1:]
|
||||
break
|
||||
} else if bbtag[j] == '>' {
|
||||
t.setValue("starting", bbtag[i+2:j])
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for j := i + 1; j < len(bbtag); j++ {
|
||||
if bbtag[j] == '>' {
|
||||
t.setValue("starting", bbtag[i+1:j])
|
||||
return
|
||||
} else if bbtag[j] == ' ' {
|
||||
t.setValue("starting", bbtag[i+1:j])
|
||||
bbtag = bbtag[j+1:]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
case '>':
|
||||
return
|
||||
case ' ':
|
||||
bbtag = bbtag[i:]
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
t.processFurther(bbtag)
|
||||
}
|
||||
|
||||
func (t *tag) processFurther(further string) {
|
||||
further = strings.TrimSpace(further)
|
||||
for i := 0; i < len(further); i++ {
|
||||
switch further[i] {
|
||||
case ' ':
|
||||
t.setValue(strings.ToLower(further[:i]), further[:i])
|
||||
further = strings.TrimSpace(further[i:])
|
||||
i = -1
|
||||
case '=':
|
||||
if qt := further[i+1]; qt == '\'' || qt == '"' {
|
||||
outloopqt:
|
||||
for j := i + 2; j < len(further); j++ {
|
||||
switch further[j] {
|
||||
case '>':
|
||||
t.setValue(strings.ToLower(further[:i]), further[i+2:j])
|
||||
return
|
||||
case qt:
|
||||
t.setValue(strings.ToLower(further[:i]), further[i+2:j])
|
||||
further = strings.TrimSpace(further[j+1:])
|
||||
i = -1
|
||||
break outloopqt
|
||||
}
|
||||
}
|
||||
} else {
|
||||
outloop:
|
||||
for j := i + 1; j < len(further); j++ {
|
||||
switch further[j] {
|
||||
case '>':
|
||||
t.setValue(strings.ToLower(further[:i]), further[i+1:j])
|
||||
return
|
||||
case ' ':
|
||||
t.setValue(strings.ToLower(further[:i]), further[i+1:j])
|
||||
further = strings.TrimSpace(further[j:])
|
||||
i = -1
|
||||
break outloop
|
||||
}
|
||||
}
|
||||
}
|
||||
case '>':
|
||||
if i != 0 {
|
||||
t.setValue(strings.ToLower(further[:i]), further[:i])
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package appimg
|
||||
|
||||
type appimg struct {
|
||||
full string
|
||||
name string
|
||||
version string
|
||||
}
|
||||
|
||||
func newApp(name string) appimg {
|
||||
var out appimg
|
||||
out.full = name
|
||||
return out
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package appimg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/gotk3/gotk3/gtk"
|
||||
)
|
||||
|
||||
func downloadApp(parent *gtk.Window, ap appimg) {
|
||||
parent.SetSensitive(false)
|
||||
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
|
||||
win.SetTransientFor(parent)
|
||||
win.Connect("destroy", func() {
|
||||
parent.SetSensitive(true)
|
||||
})
|
||||
spn, _ := gtk.SpinnerNew()
|
||||
spn.Start()
|
||||
lbl, _ := gtk.LabelNew("Downloading " + ap.full + "...")
|
||||
box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||
box.SetMarginStart(10)
|
||||
box.SetMarginEnd(10)
|
||||
box.SetMarginTop(10)
|
||||
box.SetMarginBottom(10)
|
||||
box.Add(spn)
|
||||
box.Add(lbl)
|
||||
win.Add(box)
|
||||
win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
win.ShowAll()
|
||||
win.Show()
|
||||
go func(win *gtk.Window, ap appimg) {
|
||||
defer win.Close()
|
||||
check := http.Client{
|
||||
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||
r.URL.Opaque = r.URL.Path
|
||||
return nil
|
||||
},
|
||||
}
|
||||
resp, err := check.Get(urlBase + ap.full)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
name := strings.Split(ap.full, "-")[0]
|
||||
var foldName string
|
||||
if _, err = os.Open("PortableApps/" + name + "Portable"); err == nil {
|
||||
foldName = "PortableApps/" + name + "Portable"
|
||||
} else if _, err = os.Open("PortableApps/" + name); err == nil {
|
||||
foldName = "PortableApps/" + name
|
||||
} else {
|
||||
os.Mkdir("PortableApps/"+name+"Portable", 0777)
|
||||
foldName = "PortableApps/" + name + "Portable"
|
||||
}
|
||||
os.Remove(foldName + "/" + ap.full)
|
||||
fil, err := os.Create(foldName + "/" + ap.full)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
io.Copy(fil, resp.Body)
|
||||
fil.Chmod(0777)
|
||||
}(win, ap)
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
//Package appimg is for downloading new AppImages for LinuxPA
|
||||
package appimg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/gotk3/gotk3/glib"
|
||||
"github.com/gotk3/gotk3/gtk"
|
||||
)
|
||||
|
||||
const (
|
||||
urlBase = "https://dl.bintray.com/probono/AppImages/"
|
||||
)
|
||||
|
||||
//ShowUI shows the list of possible AppImages to be downloaded in a gtk.Window
|
||||
func ShowUI(newestVersionOnly bool, clsFunc func()) {
|
||||
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
|
||||
win.Connect("destroy", func() {
|
||||
clsFunc()
|
||||
})
|
||||
apps := make([]appimg, 0)
|
||||
win.SetSizeRequest(400, 400)
|
||||
box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||
appList, _ := gtk.ListBoxNew()
|
||||
apch := make(chan appimg)
|
||||
appList.SetHExpand(true)
|
||||
appList.SetVExpand(true)
|
||||
vScrollCat, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
||||
hScrollCat, _ := gtk.AdjustmentNew(0, 0, 0, 0, 0, 0)
|
||||
lst, _ := gtk.ScrolledWindowNew(hScrollCat, vScrollCat)
|
||||
lst.SetSizeRequest(170, 500)
|
||||
lst.Add(appList)
|
||||
box.Add(lst)
|
||||
win.Add(box)
|
||||
appList.Connect("row-activated", func() {
|
||||
if appList.GetSelectedRow().GetIndex() >= 0 {
|
||||
downloadApp(win, apps[appList.GetSelectedRow().GetIndex()])
|
||||
}
|
||||
})
|
||||
win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
win.ShowAll()
|
||||
win.Show()
|
||||
getList(win, apch)
|
||||
go func(win *gtk.Window, apch chan appimg, list *gtk.ListBox) {
|
||||
if newestVersionOnly {
|
||||
imgs := make([]appimg, 0)
|
||||
a := make(map[string][]appimg)
|
||||
names := make([]string, 0)
|
||||
for i := range apch {
|
||||
imgs = append(imgs, i)
|
||||
}
|
||||
for i, v := range imgs {
|
||||
sp := strings.Split(v.full, "-")
|
||||
if len(sp) >= 2 {
|
||||
vers := sp[1]
|
||||
removeLetters(vers)
|
||||
imgs[i].version = vers
|
||||
imgs[i].name = sp[0]
|
||||
if _, ok := a[imgs[i].name]; !ok {
|
||||
names = append(names, imgs[i].name)
|
||||
}
|
||||
a[imgs[i].name] = append(a[imgs[i].name], imgs[i])
|
||||
}
|
||||
}
|
||||
sort.Strings(names)
|
||||
for _, name := range names {
|
||||
glib.IdleAdd(func(name string, list *gtk.ListBox, i appimg) {
|
||||
lbl, _ := gtk.LabelNew(name)
|
||||
list.Add(lbl)
|
||||
apps = append(apps, i)
|
||||
lbl.Show()
|
||||
}, name, list, a[name][compareVersions(a[name])])
|
||||
}
|
||||
} else {
|
||||
for i := range apch {
|
||||
glib.IdleAdd(func(list *gtk.ListBox, i appimg) {
|
||||
lbl, _ := gtk.LabelNew(i.full)
|
||||
list.Add(lbl)
|
||||
apps = append(apps, i)
|
||||
lbl.Show()
|
||||
}, list, i)
|
||||
}
|
||||
}
|
||||
}(win, apch, appList)
|
||||
}
|
||||
|
||||
func getList(parent *gtk.Window, apch chan appimg) {
|
||||
win, _ := gtk.WindowNew(gtk.WINDOW_POPUP)
|
||||
win.SetTransientFor(parent)
|
||||
win.SetDestroyWithParent(true)
|
||||
win.Connect("destroy", func() {
|
||||
parent.SetSensitive(true)
|
||||
})
|
||||
parent.SetSensitive(false)
|
||||
spin, _ := gtk.SpinnerNew()
|
||||
spin.Start()
|
||||
txt, _ := gtk.LabelNew("Getting List...")
|
||||
box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||
box.SetMarginBottom(10)
|
||||
box.SetMarginEnd(10)
|
||||
box.SetMarginStart(10)
|
||||
box.SetMarginTop(10)
|
||||
box.Add(spin)
|
||||
box.Add(txt)
|
||||
win.Add(box)
|
||||
win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
win.ShowAll()
|
||||
win.Show()
|
||||
go func(win *gtk.Window, apch chan appimg) {
|
||||
check := http.Client{
|
||||
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||
r.URL.Opaque = r.URL.Path
|
||||
return nil
|
||||
},
|
||||
}
|
||||
resp, err := check.Get(urlBase)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
close(apch)
|
||||
win.Close()
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
btys, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
close(apch)
|
||||
win.Close()
|
||||
return
|
||||
}
|
||||
tgs := convert(string(btys))
|
||||
for _, v := range tgs {
|
||||
if strings.HasSuffix(strings.ToLower(v.Meat), ".appimage") {
|
||||
apch <- newApp(v.Meat)
|
||||
}
|
||||
}
|
||||
close(apch)
|
||||
win.Close()
|
||||
}(win, apch)
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package appimg
|
||||
|
||||
import "strings"
|
||||
|
||||
func removeLetters(vers string) string {
|
||||
vers = strings.ToLower(vers)
|
||||
letters := []string{"abcdefghijklmnopqrstuvwxyz"}
|
||||
for _, v := range letters {
|
||||
vers = strings.Replace(vers, v, "", -1)
|
||||
}
|
||||
return vers
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package appimg
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func compareVersions(imgs []appimg) int {
|
||||
for i := range imgs {
|
||||
imgs[i].version = removeLetters(imgs[i].version)
|
||||
}
|
||||
highest := 0
|
||||
higharr := strings.Split(imgs[0].version, ".")
|
||||
for i := 0; i < len(imgs); i++ {
|
||||
if i != highest {
|
||||
varr := strings.Split(imgs[i].version, ".")
|
||||
if len(higharr) < len(varr) {
|
||||
for j := 0; j < len(higharr); j++ {
|
||||
h, _ := strconv.Atoi(higharr[j])
|
||||
c, _ := strconv.Atoi(varr[j])
|
||||
if h > c {
|
||||
break
|
||||
} else if c > h {
|
||||
highest = i
|
||||
higharr = varr
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return highest
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
module github.com/CalebQ42/LinuxPA
|
||||
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/CalebQ42/GoAppImage v0.4.0
|
||||
github.com/gotk3/gotk3 v0.6.1
|
||||
github.com/mholt/archiver/v3 v3.5.1
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/adrg/xdg v0.2.2 // indirect
|
||||
github.com/andybalholm/brotli v1.0.1 // indirect
|
||||
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
|
||||
github.com/golang/snappy v0.0.2 // indirect
|
||||
github.com/klauspost/compress v1.11.4 // indirect
|
||||
github.com/klauspost/pgzip v1.2.5 // indirect
|
||||
github.com/nwaples/rardecode v1.1.0 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.2 // indirect
|
||||
github.com/ulikunitz/xz v0.5.9 // indirect
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
||||
go.lsp.dev/uri v0.3.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71 // indirect
|
||||
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||
)
|
||||
@@ -0,0 +1,70 @@
|
||||
github.com/CalebQ42/GoAppImage v0.4.0 h1:aF+Y/vyo/RGhoyZEW1CMY6WyRWrZZO4ydsRFAtIGnaY=
|
||||
github.com/CalebQ42/GoAppImage v0.4.0/go.mod h1:qHudJKAn/dlkNWNnH4h1YKXp29EZ7Bppsn7sNP2HuvU=
|
||||
github.com/adrg/xdg v0.2.2 h1:A7ZHKRz5KGOLJX/bg7IPzStryhvCzAE1wX+KWawPiAo=
|
||||
github.com/adrg/xdg v0.2.2/go.mod h1:7I2hH/IT30IsupOpKZ5ue7/qNi3CoKzD6tL3HwpaRMQ=
|
||||
github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc=
|
||||
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY=
|
||||
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s=
|
||||
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
|
||||
github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw=
|
||||
github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gotk3/gotk3 v0.6.1 h1:GJ400a0ecEEWrzjBvzBzH+pB/esEMIGdB9zPSmBdoeo=
|
||||
github.com/gotk3/gotk3 v0.6.1/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.11.4 h1:kz40R/YWls3iqT9zX9AHN3WoVsrAWVyui5sxuLqiXqU=
|
||||
github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE=
|
||||
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo=
|
||||
github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ=
|
||||
github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
|
||||
github.com/pierrec/lz4/v4 v4.1.2 h1:qvY3YFXRQE/XB8MlLzJH7mSzBs74eA2gg52YTk6jUPM=
|
||||
github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I=
|
||||
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
|
||||
go.lsp.dev/uri v0.3.0 h1:KcZJmh6nFIBeJzTugn5JTU6OOyG0lDOo3R9KwTxTYbo=
|
||||
go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71 h1:X/2sJAybVknnUnV7AD2HdT6rm2p5BP6eH2j+igduWgk=
|
||||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
|
||||
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -1,82 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/nelsam/gxui"
|
||||
"github.com/nelsam/gxui/drivers/gl"
|
||||
"github.com/nelsam/gxui/themes/dark"
|
||||
"github.com/nelsam/gxui/themes/light"
|
||||
)
|
||||
|
||||
const (
|
||||
version = "1.1.0.0"
|
||||
defIni = "[basic]\ntheme=dk"
|
||||
)
|
||||
|
||||
var (
|
||||
dr gxui.Driver
|
||||
th gxui.Theme
|
||||
master map[string][]app
|
||||
linmaster map[string][]app
|
||||
cats []string
|
||||
lin []string
|
||||
wine bool
|
||||
comEnbld bool
|
||||
darkTheme = true
|
||||
)
|
||||
|
||||
func main() {
|
||||
updated := false
|
||||
os.MkdirAll("PortableApps/LinuxPACom", 0777)
|
||||
stat, err := versionDL()
|
||||
if stat {
|
||||
res := getVersionFileInfo()
|
||||
if res != "Error!" {
|
||||
stat, err = checkForUpdate(res)
|
||||
if stat {
|
||||
downloadUpdate(res)
|
||||
updated = true
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Failed Version File Info")
|
||||
}
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if updated {
|
||||
cmd := exec.Command("./LinuxPA")
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Start()
|
||||
} else {
|
||||
master = make(map[string][]app)
|
||||
linmaster = make(map[string][]app)
|
||||
gl.StartDriver(appMain)
|
||||
}
|
||||
}
|
||||
|
||||
func appMain(dri gxui.Driver) {
|
||||
dr = dri
|
||||
setup()
|
||||
if darkTheme {
|
||||
th = dark.CreateTheme(dr)
|
||||
} else {
|
||||
th = light.CreateTheme(dr)
|
||||
}
|
||||
th = dark.CreateTheme(dr)
|
||||
ui()
|
||||
}
|
||||
|
||||
func contains(arr []string, str string) bool {
|
||||
for _, v := range arr {
|
||||
if v == str {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/draw"
|
||||
_ "image/png"
|
||||
"os"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/nelsam/gxui"
|
||||
)
|
||||
|
||||
func setup() {
|
||||
PortableAppsFold, err := os.Open("PortableApps")
|
||||
if PAStat, _ := PortableAppsFold.Stat(); err != nil || !PAStat.IsDir() {
|
||||
os.Mkdir("PortableApps", 0777)
|
||||
PortableAppsFold, err = os.Open("PortableApps")
|
||||
if err != nil {
|
||||
panic("Can't find PortableApps folder and can't create one!")
|
||||
}
|
||||
}
|
||||
if _, err = os.Open("PortableApps/LinuxPACom"); err != nil {
|
||||
os.Mkdir("PortableApps/LinuxPACom", 0777)
|
||||
}
|
||||
fmt.Println(err)
|
||||
_, err = os.Open("PortableApps/LinuxPACom/common.sh")
|
||||
if err == nil {
|
||||
comEnbld = true
|
||||
}
|
||||
fi, err := os.Open("PortableApps/LinuxPACom/Info.ini")
|
||||
if err != nil {
|
||||
fi, err = os.Create("PortableApps/LinuxPACom/Info.ini")
|
||||
if err == nil {
|
||||
wrt := bufio.NewWriter(fi)
|
||||
wrt.WriteString(defIni)
|
||||
wrt.Flush()
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
rdr := bufio.NewReader(fi)
|
||||
for err != nil {
|
||||
ln, _, error := rdr.ReadLine()
|
||||
err = error
|
||||
str := string(ln)
|
||||
if strings.HasPrefix(str, "theme=") {
|
||||
str = strings.TrimPrefix(str, "theme=")
|
||||
if str == "lt" {
|
||||
darkTheme = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PAFolds, _ := PortableAppsFold.Readdirnames(-1)
|
||||
sort.Strings(PAFolds)
|
||||
for _, v := range PAFolds {
|
||||
fold, _ := os.Open("PortableApps/" + v)
|
||||
if stat, _ := fold.Stat(); stat.IsDir() && stat.Name() != "PortableApps.com" && stat.Name() != "LinuxPACom" {
|
||||
ap := processApp("PortableApps/" + v)
|
||||
if !reflect.DeepEqual(ap, app{}) {
|
||||
if _, ok := master[ap.cat]; !ok {
|
||||
cats = append(cats, ap.cat)
|
||||
sort.Strings(cats)
|
||||
}
|
||||
if len(ap.lin) != 0 {
|
||||
if _, ok := linmaster[ap.cat]; !ok {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func processApp(fold string) (out app) {
|
||||
wd, _ := os.Getwd()
|
||||
out.dir = wd + "/" + fold
|
||||
out.ini = findInfo(fold)
|
||||
if out.ini != nil {
|
||||
out.name = getName(out.ini)
|
||||
out.ini = findInfo(fold)
|
||||
out.cat = getCat(out.ini)
|
||||
out.ini = findInfo(fold)
|
||||
}
|
||||
if out.name == "" {
|
||||
out.name = strings.TrimPrefix(fold, "PortableApps/")
|
||||
}
|
||||
if out.cat == "" {
|
||||
out.cat = "Other"
|
||||
}
|
||||
out.icon = getIcon(fold)
|
||||
folder, _ := os.Open(fold)
|
||||
fis, _ := folder.Readdirnames(-1)
|
||||
for _, v := range fis {
|
||||
tmp, _ := os.Open(fold + "/" + v)
|
||||
if stat, _ := tmp.Stat(); stat.IsDir() {
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(strings.ToLower(v), ".appimage") {
|
||||
out.appimg = append(out.appimg, v)
|
||||
out.ex = append(out.ex, v)
|
||||
out.lin = append(out.lin, v)
|
||||
} else if strings.HasSuffix(strings.ToLower(v), ".exe") {
|
||||
out.ex = append(out.ex, v)
|
||||
} else {
|
||||
btys := make([]byte, 4)
|
||||
rdr := bufio.NewReader(tmp)
|
||||
rdr.Read(btys)
|
||||
if (strings.Contains(strings.ToLower(string(btys)), "elf") && !strings.HasSuffix(strings.ToLower(v), ".so") && !strings.Contains(v, ".so.")) || strings.HasPrefix(strings.ToLower(string(btys)), "#!") {
|
||||
out.ex = append(out.ex, v)
|
||||
out.lin = append(out.lin, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(out.ex) == 0 {
|
||||
return app{}
|
||||
}
|
||||
if len(out.lin) == 0 {
|
||||
out.name += " (Wine)"
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getCat(ini *os.File) string {
|
||||
rdr := bufio.NewReader(ini)
|
||||
var ret string
|
||||
for line, _, err := rdr.ReadLine(); err == nil; line, _, err = rdr.ReadLine() {
|
||||
if strings.HasPrefix(string(line), "Category=") {
|
||||
ret = strings.TrimPrefix(string(line), "Category=")
|
||||
break
|
||||
}
|
||||
}
|
||||
rdr.Reset(ini)
|
||||
return ret
|
||||
}
|
||||
|
||||
func getName(ini *os.File) string {
|
||||
rdr := bufio.NewReader(ini)
|
||||
var ret string
|
||||
for line, _, err := rdr.ReadLine(); err == nil; line, _, err = rdr.ReadLine() {
|
||||
if strings.HasPrefix(string(line), "Name=") {
|
||||
ret = strings.TrimPrefix(string(line), "Name=")
|
||||
break
|
||||
}
|
||||
}
|
||||
rdr.Reset(ini)
|
||||
return ret
|
||||
}
|
||||
|
||||
func getIcon(fold string) gxui.Texture {
|
||||
var pic *os.File
|
||||
if folder, err := os.Open(fold + "/App/AppInfo"); err == nil {
|
||||
fis, _ := folder.Readdir(-1)
|
||||
var pics []string
|
||||
for _, v := range fis {
|
||||
if !v.IsDir() && strings.HasSuffix(strings.ToLower(v.Name()), ".png") && strings.HasPrefix(strings.ToLower(v.Name()), "appicon_") {
|
||||
pics = append(pics, v.Name())
|
||||
}
|
||||
}
|
||||
sort.Strings(pics)
|
||||
if len(pics) > 1 {
|
||||
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])
|
||||
}
|
||||
} else if fi, err := os.Open(fold + "/appicon.png"); err == nil {
|
||||
pic = fi
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
img, _, err := image.Decode(pic)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
rgba := image.NewRGBA(img.Bounds())
|
||||
draw.Draw(rgba, img.Bounds(), img, image.ZP, draw.Src)
|
||||
ret := dr.CreateTexture(rgba, 1)
|
||||
return ret
|
||||
}
|
||||
|
||||
func findInfo(fold string) *os.File {
|
||||
tmp, err := os.Open(fold + "/App/AppInfo")
|
||||
if err == nil {
|
||||
fis, _ := tmp.Readdirnames(-1)
|
||||
for _, v := range fis {
|
||||
if strings.ToLower(v) == "appinfo.ini" {
|
||||
tmp, _ := os.Open(fold + "/App/AppInfo/" + v)
|
||||
return tmp
|
||||
}
|
||||
}
|
||||
}
|
||||
if fi, err := os.Open(fold + "/appinfo.ini"); err == nil {
|
||||
return fi
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/nelsam/gxui"
|
||||
"github.com/nelsam/gxui/math"
|
||||
)
|
||||
|
||||
//StrList TODO
|
||||
type StrList struct {
|
||||
gxui.AdapterBase
|
||||
strs []string
|
||||
}
|
||||
|
||||
//AddString TODO
|
||||
func (s *StrList) AddString(add string) {
|
||||
s.strs = append(s.strs, add)
|
||||
s.DataChanged(false)
|
||||
}
|
||||
|
||||
//Remove TODO
|
||||
func (s *StrList) Remove(index int) {
|
||||
s.strs = append(s.strs[:index], s.strs[index+1:]...)
|
||||
s.DataChanged(false)
|
||||
}
|
||||
|
||||
//SetStrings TODO
|
||||
func (s *StrList) SetStrings(strs []string) {
|
||||
s.strs = strs
|
||||
s.DataChanged(false)
|
||||
}
|
||||
|
||||
//Count TODO
|
||||
func (s *StrList) Count() int {
|
||||
return len(s.strs)
|
||||
}
|
||||
|
||||
//ItemAt TODO
|
||||
func (s *StrList) ItemAt(index int) gxui.AdapterItem {
|
||||
return s.strs[index]
|
||||
}
|
||||
|
||||
//ItemIndex TODO
|
||||
func (s *StrList) ItemIndex(item gxui.AdapterItem) int {
|
||||
for i, v := range s.strs {
|
||||
if v == item {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
//Create TODO
|
||||
func (s *StrList) Create(th gxui.Theme, index int) gxui.Control {
|
||||
box := th.CreateLinearLayout()
|
||||
box.SetDirection(gxui.LeftToRight)
|
||||
lbl := th.CreateLabel()
|
||||
lbl.SetText(s.strs[index])
|
||||
box.AddChild(lbl)
|
||||
return box
|
||||
}
|
||||
|
||||
//Size TODO
|
||||
func (s *StrList) Size(gxui.Theme) math.Size {
|
||||
return math.Size{W: math.MaxSize.W, H: 20}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/nelsam/gxui"
|
||||
)
|
||||
|
||||
func ui() {
|
||||
catListAdap := &StrList{}
|
||||
appListAdap := &catAdap{}
|
||||
catListAdap.SetStrings(lin)
|
||||
win := th.CreateWindow(500, 500, "LinuxPA")
|
||||
top := th.CreateLinearLayout()
|
||||
top.SetDirection(gxui.BottomToTop)
|
||||
splBox := th.CreateLinearLayout()
|
||||
spl := th.CreateSplitterLayout()
|
||||
spl.SetOrientation(gxui.Horizontal)
|
||||
catList := th.CreateList()
|
||||
catList.SetAdapter(catListAdap)
|
||||
catList.OnSelectionChanged(func(it gxui.AdapterItem) {
|
||||
appListAdap.setCat(it.(string))
|
||||
})
|
||||
appList := th.CreateTree()
|
||||
appList.SetAdapter(appListAdap)
|
||||
spl.AddChild(catList)
|
||||
spl.AddChild(appList)
|
||||
splBox.AddChild(spl)
|
||||
butBox := th.CreateLinearLayout()
|
||||
butBox.SetDirection(gxui.LeftToRight)
|
||||
if _, err := exec.LookPath("wine"); err == nil {
|
||||
wineBut := th.CreateButton()
|
||||
wineBut.SetType(gxui.ToggleButton)
|
||||
wineBut.SetChecked(wine)
|
||||
wineBut.SetText("Show Windows Apps")
|
||||
wineBut.OnClick(func(gxui.MouseEvent) {
|
||||
wine = wineBut.IsChecked()
|
||||
appListAdap.refresh()
|
||||
if wineBut.IsChecked() {
|
||||
catListAdap.SetStrings(cats)
|
||||
wineBut.SetText("Hide Windows Apps")
|
||||
} else {
|
||||
catListAdap.SetStrings(lin)
|
||||
wineBut.SetText("Show Windows Apps")
|
||||
}
|
||||
})
|
||||
_, err := os.Open("Start.exe")
|
||||
if err == nil {
|
||||
pa := th.CreateButton()
|
||||
pa.SetText("Open PortableApps Launcher")
|
||||
pa.OnClick(func(gxui.MouseEvent) {
|
||||
cmd := exec.Command("wine", "Start.exe")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Start()
|
||||
})
|
||||
butBox.AddChild(pa)
|
||||
}
|
||||
butBox.AddChild(wineBut)
|
||||
}
|
||||
top.AddChild(butBox)
|
||||
top.AddChild(splBox)
|
||||
win.AddChild(top)
|
||||
win.OnClose(dr.Terminate)
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -10,20 +9,16 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
version = "2.1.2.1"
|
||||
version = "2.2.0.0"
|
||||
)
|
||||
|
||||
var (
|
||||
master map[string][]app
|
||||
linmaster map[string][]app
|
||||
cats []string
|
||||
lin []string
|
||||
wine bool
|
||||
comEnbld bool
|
||||
wineAvail bool
|
||||
portableHide bool
|
||||
versionNewest = true
|
||||
paDirs = true
|
||||
master map[string][]app
|
||||
linmaster map[string][]app
|
||||
cats []string
|
||||
lin []string
|
||||
comEnbld bool
|
||||
populated bool
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -56,55 +51,6 @@ func uiStart(forced bool) {
|
||||
gtk.Main()
|
||||
}
|
||||
|
||||
func savePrefs() {
|
||||
os.Remove("PortableApps/LinuxPACom/Prefs.gob")
|
||||
fil, err := os.Create("PortableApps/LinuxPACom/Prefs.gob")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
enc := gob.NewEncoder(fil)
|
||||
err = enc.Encode(wine)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = enc.Encode(portableHide)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = enc.Encode(versionNewest)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = enc.Encode(paDirs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func loadPrefs() {
|
||||
fil, err := os.Open("PortableApps/LinuxPACom/Prefs.gob")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
dec := gob.NewDecoder(fil)
|
||||
err = dec.Decode(&wine)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dec.Decode(&portableHide)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dec.Decode(&versionNewest)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dec.Decode(&paDirs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func contains(arr []string, str string) bool {
|
||||
for _, v := range arr {
|
||||
if v == str {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
wine bool
|
||||
wineAvail bool
|
||||
portableHide bool
|
||||
betaUpdate bool
|
||||
versionNewest = true
|
||||
paDirs = true
|
||||
)
|
||||
|
||||
func savePrefs() {
|
||||
os.Remove("PortableApps/LinuxPACom/Prefs.gob")
|
||||
fil, err := os.Create("PortableApps/LinuxPACom/Prefs.gob")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
enc := gob.NewEncoder(fil)
|
||||
err = enc.Encode(wine)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = enc.Encode(portableHide)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = enc.Encode(versionNewest)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = enc.Encode(paDirs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = enc.Encode(betaUpdate)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func loadPrefs() {
|
||||
fil, err := os.Open("PortableApps/LinuxPACom/Prefs.gob")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
dec := gob.NewDecoder(fil)
|
||||
err = dec.Decode(&wine)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dec.Decode(&portableHide)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dec.Decode(&versionNewest)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dec.Decode(&paDirs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dec.Decode(&betaUpdate)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ func settingsUI(parent *gtk.Window, onExit func()) {
|
||||
win.SetDefaultSize(600, 300)
|
||||
win.SetPosition(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
win.Connect("destroy", func() {
|
||||
savePrefs()
|
||||
parent.SetSensitive(true)
|
||||
onExit()
|
||||
})
|
||||
@@ -93,12 +94,14 @@ func settingsUI(parent *gtk.Window, onExit func()) {
|
||||
paDirsCheck.Connect("toggled", func() {
|
||||
paDirs = paDirsCheck.GetActive()
|
||||
})
|
||||
betaCheck, _ := gtk.CheckButtonNewWithLabel("Update to beta releases")
|
||||
gnrl.Add(wineLbl)
|
||||
gnrl.Add(dlWine)
|
||||
gnrl.Add(pthdCheck)
|
||||
gnrl.Add(wineCheck)
|
||||
gnrl.Add(versCheck)
|
||||
gnrl.Add(paDirsCheck)
|
||||
gnrl.Add(betaCheck)
|
||||
ntbk.AppendPage(gnrl, getLabel("General"))
|
||||
com, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||
com.SetMarginStart(10)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
goappimage "github.com/CalebQ42/GoAppImage"
|
||||
"github.com/gotk3/gotk3/gdk"
|
||||
"github.com/gotk3/gotk3/gtk"
|
||||
)
|
||||
@@ -64,35 +65,21 @@ func setup() {
|
||||
}
|
||||
}
|
||||
}
|
||||
populated = true
|
||||
}
|
||||
|
||||
func processApp(fold string) (out app) {
|
||||
wd, _ := os.Getwd()
|
||||
out.dir = wd + "/" + fold
|
||||
out.ini = findInfo(fold)
|
||||
if out.ini != nil {
|
||||
out.name = getName(out.ini)
|
||||
out.ini = findInfo(fold)
|
||||
out.cat = getCat(out.ini)
|
||||
out.ini = findInfo(fold)
|
||||
}
|
||||
if out.name == "" {
|
||||
out.name = strings.TrimPrefix(fold, "PortableApps/")
|
||||
}
|
||||
if out.cat == "" {
|
||||
out.cat = "Other"
|
||||
}
|
||||
if portableHide {
|
||||
out.name = strings.TrimSuffix(out.name, "Portable")
|
||||
}
|
||||
out.icon = getIcon(fold)
|
||||
folder, _ := os.Open(fold)
|
||||
fis, _ := folder.Readdirnames(-1)
|
||||
for _, v := range fis {
|
||||
tmp, _ := os.Open(fold + "/" + v)
|
||||
if stat, _ := tmp.Stat(); stat.IsDir() {
|
||||
stat, _ := tmp.Stat()
|
||||
if stat.IsDir() {
|
||||
continue
|
||||
}
|
||||
//TODO: check permission to see if it has exec permission
|
||||
if strings.HasSuffix(strings.ToLower(v), ".appimage") {
|
||||
out.appimg = append(out.appimg, v)
|
||||
out.ex = append(out.ex, v)
|
||||
@@ -114,7 +101,90 @@ func processApp(fold string) (out app) {
|
||||
}
|
||||
if len(out.lin) == 0 {
|
||||
out.name += " (Wine)"
|
||||
out.wine = true
|
||||
}
|
||||
out.icon = getIcon(fold)
|
||||
out.ini = findInfo(fold)
|
||||
if out.ini != nil {
|
||||
out.name = getName(out.ini)
|
||||
out.cat = getCat(out.ini)
|
||||
}
|
||||
if len(out.appimg) > 0 && out.name == "" && out.cat == "" && out.icon == nil {
|
||||
os.Mkdir(out.dir+"/.appimageconfig", 0777)
|
||||
ai := goappimage.NewAppImage(out.dir + "/" + out.appimg[0])
|
||||
fil, err := os.Open(out.dir + "/.appimageconfig/the.md5")
|
||||
if os.IsNotExist(err) {
|
||||
ai.ExtractFile("*.desktop", out.dir+"/.appimageconfig/", false)
|
||||
appimageconfig, _ := os.Open(out.dir + "/.appimageconfig")
|
||||
appdirs, _ := appimageconfig.Readdirnames(-1)
|
||||
for _, dirs := range appdirs {
|
||||
desktopFil, _ := os.Open(out.dir + "/.appimageconfig/" + dirs)
|
||||
if stat, _ := desktopFil.Stat(); strings.HasSuffix(dirs, ".desktop") && !stat.IsDir() {
|
||||
os.Rename(out.dir+"/.appimageconfig/"+dirs, out.dir+"/.appimageconfig/the.desktop")
|
||||
break
|
||||
}
|
||||
}
|
||||
desk, _ := os.Open(out.dir + "/.appimageconfig/the.desktop")
|
||||
name, cat, icon := extractDesktopInfo(desk)
|
||||
if out.name == "" {
|
||||
out.name = name
|
||||
}
|
||||
if out.cat == "" {
|
||||
out.cat = cat
|
||||
}
|
||||
if out.icon == nil {
|
||||
it, _ := gtk.IconThemeGetDefault()
|
||||
out.icon, err = it.LoadIcon(icon, 64, gtk.ICON_LOOKUP_GENERIC_FALLBACK)
|
||||
}
|
||||
fil, _ = os.Create(out.dir + "/.appimageconfig/the.md5")
|
||||
wrtr := bufio.NewWriter(fil)
|
||||
wrtr.WriteString(ai.Md5)
|
||||
wrtr.Flush()
|
||||
} else {
|
||||
rdr := bufio.NewReader(fil)
|
||||
filMd, _, _ := rdr.ReadLine()
|
||||
oldMd := string(filMd)
|
||||
if oldMd != ai.Md5 {
|
||||
ai.ExtractFile("*.desktop", out.dir+"/.appimageconfig/", false)
|
||||
appimageconfig, _ := os.Open(out.dir + "/.appimageconfig")
|
||||
appdirs, _ := appimageconfig.Readdirnames(-1)
|
||||
for _, dirs := range appdirs {
|
||||
desktopFil, _ := os.Open(out.dir + "/.appimageconfig/" + dirs)
|
||||
if stat, _ := desktopFil.Stat(); strings.HasSuffix(dirs, ".desktop") && !stat.IsDir() {
|
||||
os.Rename(out.dir+"/.appimageconfig/"+dirs, out.dir+"/.appimageconfig/the.desktop")
|
||||
break
|
||||
}
|
||||
}
|
||||
os.Remove(out.dir + "/.appimageconfig/the.md5")
|
||||
fil, _ = os.Create(out.dir + "/.appimageconfig/the.md5")
|
||||
wrtr := bufio.NewWriter(fil)
|
||||
wrtr.WriteString(ai.Md5)
|
||||
wrtr.Flush()
|
||||
}
|
||||
}
|
||||
desk, _ := os.Open(out.dir + "/.appimageconfig/the.desktop")
|
||||
name, cat, icon := extractDesktopInfo(desk)
|
||||
if out.name == "" {
|
||||
out.name = name
|
||||
}
|
||||
if out.cat == "" {
|
||||
out.cat = cat
|
||||
}
|
||||
if out.icon == nil {
|
||||
it, _ := gtk.IconThemeGetDefault()
|
||||
out.icon, err = it.LoadIcon(icon, 32, gtk.ICON_LOOKUP_GENERIC_FALLBACK)
|
||||
}
|
||||
}
|
||||
if out.name == "" {
|
||||
out.name = strings.TrimPrefix(fold, "PortableApps/")
|
||||
}
|
||||
if out.cat == "" {
|
||||
out.cat = "Other"
|
||||
}
|
||||
if portableHide {
|
||||
out.name = strings.TrimSuffix(out.name, "Portable")
|
||||
}
|
||||
out.name = strings.TrimSpace(out.name)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -133,6 +203,31 @@ func getCat(ini *os.File) string {
|
||||
return ret
|
||||
}
|
||||
|
||||
func extractDesktopInfo(desk *os.File) (name, category, iconName string) {
|
||||
rdr := bufio.NewReader(desk)
|
||||
var nameGot, catGot, iconGot bool
|
||||
for line, _, err := rdr.ReadLine(); err == nil; line, _, err = rdr.ReadLine() {
|
||||
ln := string(line)
|
||||
if !nameGot && strings.HasPrefix(ln, "Name=") {
|
||||
name = strings.TrimPrefix(ln, "Name=")
|
||||
nameGot = true
|
||||
} else if !catGot && strings.HasPrefix(ln, "Categories=") {
|
||||
cats := strings.Split(strings.TrimPrefix(ln, "Categories="), ";")
|
||||
if len(cats) > 0 {
|
||||
category = cats[0]
|
||||
}
|
||||
catGot = true
|
||||
} else if !iconGot && strings.HasPrefix(ln, "Icon=") {
|
||||
iconName = strings.TrimPrefix(ln, "Icon=")
|
||||
iconGot = true
|
||||
}
|
||||
if nameGot && catGot && iconGot {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getName(ini *os.File) string {
|
||||
rdr := bufio.NewReader(ini)
|
||||
var ret string
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/CalebQ42/LinuxPA/appimg"
|
||||
"github.com/gotk3/gotk3/glib"
|
||||
"github.com/gotk3/gotk3/gtk"
|
||||
"github.com/pkg/browser"
|
||||
)
|
||||
|
||||
func ui(win *gtk.Window) {
|
||||
@@ -140,22 +140,8 @@ func ui(win *gtk.Window) {
|
||||
}
|
||||
})
|
||||
dnl.Connect("clicked", func() {
|
||||
appimg.ShowUI(versionNewest, func() {
|
||||
master = make(map[string][]app)
|
||||
linmaster = make(map[string][]app)
|
||||
cats = make([]string, 0)
|
||||
lin = make([]string, 0)
|
||||
setup()
|
||||
store.Clear()
|
||||
for i := range ls {
|
||||
catList.Remove(catList.GetRowAtIndex(len(ls) - i - 1))
|
||||
}
|
||||
ls = getCatRows()
|
||||
for i, v := range ls {
|
||||
catList.Insert(v, i)
|
||||
}
|
||||
catList.ShowAll()
|
||||
})
|
||||
//TODO: detect if a webbrowser app is available and use that instead
|
||||
browser.OpenURL("https://appimage.github.io/apps/")
|
||||
})
|
||||
settings.Connect("clicked", func() {
|
||||
settingsUI(win, func() {
|
||||
|
||||
@@ -15,9 +15,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
versionURL = "https://www.dropbox.com/s/a0xizzo0a4vsfqt/Version?dl=1"
|
||||
downloadURL = "https://github.com/CalebQ42/LinuxPA/releases/download/vXXX/LinuxPA"
|
||||
changelogURL = "https://www.dropbox.com/s/nmbk318er5kej5h/Changelog?dl=1"
|
||||
versionURL = "https://www.dropbox.com/s/a0xizzo0a4vsfqt/Version?dl=1"
|
||||
downloadURL = "https://github.com/CalebQ42/LinuxPA/releases/download/vXXX/LinuxPA"
|
||||
changelogURL = "https://www.dropbox.com/s/rk8ec9p14imkh03/Changelog?dl=1"
|
||||
changelogBetaURL = "https://www.dropbox.com/s/h2u34g5s8qr8sef/ChangelogBeta?dl=1"
|
||||
)
|
||||
|
||||
//Thanks to https://www.socketloop.com/tutorials/golang-download-file-example
|
||||
@@ -31,7 +32,7 @@ func versionDL() (bool, error) {
|
||||
}
|
||||
versionFile.Chmod(0777)
|
||||
check := http.Client{
|
||||
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||
CheckRedirect: func(r *http.Request, _ []*http.Request) error {
|
||||
r.URL.Opaque = r.URL.Path
|
||||
return nil
|
||||
},
|
||||
@@ -47,14 +48,17 @@ func versionDL() (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func getVersionFileInfo() string {
|
||||
func getVersionFileInfo() (stable string, beta string) {
|
||||
fil, err := os.Open("PortableApps/LinuxPACom/Version")
|
||||
if err != nil {
|
||||
return "Error!"
|
||||
return "Error!", ""
|
||||
}
|
||||
rdr := bufio.NewReader(fil)
|
||||
out, _, _ := rdr.ReadLine()
|
||||
return string(out)
|
||||
stable = string(out)
|
||||
out, _, _ = rdr.ReadLine()
|
||||
beta = string(out)
|
||||
return
|
||||
}
|
||||
|
||||
func changelogDL() (bool, error) {
|
||||
@@ -64,12 +68,17 @@ func changelogDL() (bool, error) {
|
||||
}
|
||||
changelogFile.Chmod(0777)
|
||||
check := http.Client{
|
||||
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||
CheckRedirect: func(r *http.Request, _ []*http.Request) error {
|
||||
r.URL.Opaque = r.URL.Path
|
||||
return nil
|
||||
},
|
||||
}
|
||||
response, err := check.Get(changelogURL)
|
||||
var response *http.Response
|
||||
if betaUpdate {
|
||||
response, err = check.Get(changelogBetaURL)
|
||||
} else {
|
||||
response, err = check.Get(changelogURL)
|
||||
}
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -89,7 +98,11 @@ func getChangelog() string {
|
||||
return string(out)
|
||||
}
|
||||
|
||||
func checkForUpdate(new string) (bool, error) {
|
||||
func checkForUpdate(stable, beta string) (bool, error) {
|
||||
new := stable
|
||||
if betaUpdate {
|
||||
new = beta
|
||||
}
|
||||
curSlice := strings.Split(version, ".")
|
||||
newSlice := strings.Split(new, ".")
|
||||
curNums := make([]int, 4)
|
||||
@@ -128,7 +141,7 @@ func downloadUpdate(newVersion string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
check := http.Client{
|
||||
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||
CheckRedirect: func(r *http.Request, _ []*http.Request) error {
|
||||
r.URL.Opaque = r.URL.Path
|
||||
return nil
|
||||
},
|
||||
@@ -148,20 +161,22 @@ func downloadUpdate(newVersion string) (bool, error) {
|
||||
func update(win *gtk.Window, forced bool) {
|
||||
stat, err := versionDL()
|
||||
if stat {
|
||||
res := getVersionFileInfo()
|
||||
if res != "Error!" {
|
||||
stat, err = checkForUpdate(res)
|
||||
stable, beta := getVersionFileInfo()
|
||||
if stable != "Error!" {
|
||||
stat, err = checkForUpdate(stable, beta)
|
||||
if stat || forced {
|
||||
stat, err = changelogDL()
|
||||
if stat {
|
||||
updateWin, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
|
||||
updateWin.SetTransientFor(win)
|
||||
updateWin.SetPosition(gtk.WIN_POS_CENTER)
|
||||
updateWin.SetDefaultSize(600, 300)
|
||||
topLvl, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
|
||||
lbl, _ := gtk.LabelNew("There's a new update! Here's the changelog:")
|
||||
tagTbl, _ := gtk.TextTagTableNew()
|
||||
buf, _ := gtk.TextBufferNew(tagTbl)
|
||||
tv, _ := gtk.TextViewNewWithBuffer(buf)
|
||||
tv.SetWrapMode(gtk.WRAP_WORD)
|
||||
tv.SetEditable(false)
|
||||
buf.SetText(getChangelog())
|
||||
butBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 5)
|
||||
@@ -222,11 +237,15 @@ func actuallyUpdate(win *gtk.Window, forced bool) {
|
||||
defer updateWin.Close()
|
||||
stat, err := versionDL()
|
||||
if stat {
|
||||
res := getVersionFileInfo()
|
||||
if res != "Error!" {
|
||||
stat, err = checkForUpdate(res)
|
||||
stable, beta := getVersionFileInfo()
|
||||
if stable != "Error!" {
|
||||
stat, err = checkForUpdate(stable, beta)
|
||||
if stat || forced {
|
||||
downloadUpdate(res)
|
||||
if betaUpdate {
|
||||
downloadUpdate(beta)
|
||||
} else {
|
||||
downloadUpdate(stable)
|
||||
}
|
||||
win.Close()
|
||||
cmd := exec.Command("./LinuxPA")
|
||||
cmd.Stdin = os.Stdin
|
||||
|
||||
@@ -9,11 +9,11 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/gotk3/gotk3/gtk"
|
||||
"github.com/mholt/archiver"
|
||||
"github.com/mholt/archiver/v3"
|
||||
)
|
||||
|
||||
const (
|
||||
wineURL = "https://www.playonlinux.com/wine/binaries/linux-amd64/PlayOnLinux-wine-2.5-linux-amd64.pol"
|
||||
wineURL = "https://www.playonlinux.com/wine/binaries/phoenicis/staging-linux-amd64/PlayOnLinux-wine-5.20-staging-linux-amd64.tar.gz"
|
||||
)
|
||||
|
||||
func downloadWine(parent *gtk.Window, cb chan bool) {
|
||||
@@ -40,7 +40,7 @@ func downloadWine(parent *gtk.Window, cb chan bool) {
|
||||
win.Show()
|
||||
go func(win *gtk.Window, txt *gtk.Label) {
|
||||
defer win.Close()
|
||||
wineTar, err := os.Create("PortableApps/LinuxPACom/wine2.5.tar.bz2")
|
||||
wineTar, err := os.Create("PortableApps/LinuxPACom/wine5.20.tar.bz2")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
cb <- false
|
||||
@@ -48,7 +48,7 @@ func downloadWine(parent *gtk.Window, cb chan bool) {
|
||||
}
|
||||
defer wineTar.Close()
|
||||
check := http.Client{
|
||||
CheckRedirect: func(r *http.Request, via []*http.Request) error {
|
||||
CheckRedirect: func(r *http.Request, _ []*http.Request) error {
|
||||
r.URL.Opaque = r.URL.Path
|
||||
return nil
|
||||
},
|
||||
@@ -68,7 +68,7 @@ func downloadWine(parent *gtk.Window, cb chan bool) {
|
||||
return
|
||||
}
|
||||
txt.SetText("Extracting Wine")
|
||||
err = archiver.TarBz2.Open("PortableApps/LinuxPACom/wine2.5.tar.bz2", "PortableApps/LinuxPACom/Wine")
|
||||
err = archiver.DefaultTarBz2.Unarchive("PortableApps/LinuxPACom/wine2.5.tar.bz2", "PortableApps/LinuxPACom/Wine")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
cb <- false
|
||||
|
||||
Reference in New Issue
Block a user