diff --git a/linux/cwtch.desktop b/linux/cwtch.desktop index 9459767a..4127dda4 100644 --- a/linux/cwtch.desktop +++ b/linux/cwtch.desktop @@ -2,7 +2,7 @@ Name=Cwtch Comment=Metadata Resistant Instant Messaging Exec=~/.local/bin/cwtch -Icon=~/.local/share/icons/cwtch.png +Icon=cwtch StartupNotify=true Type=Application Keywords=Internet;IM;Instant Messaging;Messaging;Chat diff --git a/linux/cwtch.png b/linux/cwtch.png deleted file mode 100644 index f35daeff..00000000 Binary files a/linux/cwtch.png and /dev/null differ diff --git a/linux/icons/hicolor/128x128/apps/cwtch.png b/linux/icons/hicolor/128x128/apps/cwtch.png new file mode 100644 index 00000000..ef922530 Binary files /dev/null and b/linux/icons/hicolor/128x128/apps/cwtch.png differ diff --git a/linux/icons/hicolor/16x16/apps/cwtch.png b/linux/icons/hicolor/16x16/apps/cwtch.png new file mode 100644 index 00000000..66cc4baf Binary files /dev/null and b/linux/icons/hicolor/16x16/apps/cwtch.png differ diff --git a/linux/icons/hicolor/32x32/apps/cwtch.png b/linux/icons/hicolor/32x32/apps/cwtch.png new file mode 100644 index 00000000..716f583b Binary files /dev/null and b/linux/icons/hicolor/32x32/apps/cwtch.png differ diff --git a/linux/icons/hicolor/48x48/apps/cwtch.png b/linux/icons/hicolor/48x48/apps/cwtch.png new file mode 100644 index 00000000..2396ee05 Binary files /dev/null and b/linux/icons/hicolor/48x48/apps/cwtch.png differ diff --git a/linux/icons/hicolor/64x64/apps/cwtch.png b/linux/icons/hicolor/64x64/apps/cwtch.png new file mode 100644 index 00000000..b49f96fe Binary files /dev/null and b/linux/icons/hicolor/64x64/apps/cwtch.png differ diff --git a/linux/install.sh b/linux/install.sh index 2f6ae01f..8c5a1f00 100755 --- a/linux/install.sh +++ b/linux/install.sh @@ -6,5 +6,10 @@ cp ui ~/.local/bin/cwtch mkdir -p ~/.local/share/icons cp cwtch.png ~/.local/share/icons +mkdir -p ~/.local/share/cwtch +cp -r assets ~/.local/share/cwtch + +cp -r icons ~/.local/share/ + mkdir -p ~/.local/share/applications sed "s|~|$HOME|" cwtch.desktop > $HOME/.local/share/applications/cwtch.desktop diff --git a/main.go b/main.go index 7bbe771c..2feb320f 100644 --- a/main.go +++ b/main.go @@ -181,14 +181,38 @@ func mainUi(flagLocal bool, flagClientUI bool) { log.Infof("core.QCoreApplication_ApplicationDirPath(): %v\n", dir) if runtime.GOOS == "android" { gcd.SetAssetPath("assets:/") - } else { + } else if runtime.GOOS == "windows" { // all of these access are QML based, and QML takes URIs which use forward slashes and translates them to local OS sperators // also windows paths need to be like /c:/PATH - if runtime.GOOS == "windows" { - dir = "/" + dir - } + dir = "/" + dir // QML uses '/' regardless of platform (so we use path.Join here not filepath.Join) gcd.SetAssetPath("file://" + path.Join(dir, "assets") + "/") + } else { + if buildVer == "" || flagLocal { + if _, err := os.Stat(path.Join(dir, "assets")); !os.IsNotExist(err) { + gcd.SetAssetPath("file://" + path.Join(dir, "assets") + "/") + } + } else { + usr, err := user.Current() + if err != nil { + log.Errorf("\nerror: could not load current user: %v\n", err) + os.Exit(1) + } + localCwtch := path.Join(usr.HomeDir, ".local/share/cwtch") + if _, err := os.Stat(localCwtch); !os.IsNotExist(err) { + gcd.SetAssetPath("file://" + path.Join(localCwtch, "assets") + "/") + } else if _, err := os.Stat("/usr/share/cwtch"); !os.IsNotExist(err) { + gcd.SetAssetPath("file://" + "/usr/share/cwtch/assets/") + } else if _, err := os.Stat("/usr/local/share/cwtch/"); !os.IsNotExist(err) { + gcd.SetAssetPath("file://" + "/usr/local/share/cwtch/assets/") + } else if _, err := os.Stat(path.Join(dir, "assets")); !os.IsNotExist(err) { + gcd.SetAssetPath("file://" + path.Join(dir, "assets") + "/") + } + } + if gcd.AssetPath() == "" { + log.Errorf("Could not find assets folder") + os.Exit(-1) + } } log.Infof("gcd.assetPath = '%v'\n", gcd.AssetPath())