Unverified Commit cfa9a512 authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

gui-for-singbox: 1.13.0 -> 1.15.1 (#464771)

parents 3a45ffd7 980b3c9c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -16,13 +16,13 @@

let
  pname = "gui-for-singbox";
  version = "1.13.0";
  version = "1.15.1";

  src = fetchFromGitHub {
    owner = "GUI-for-Cores";
    repo = "GUI.for.SingBox";
    tag = "v${version}";
    hash = "sha256-oReDI6w+N82f+DSv1mPvr0hPG7CJ7CbIFljhSNQ86cI=";
    hash = "sha256-OMZrLceu/7QTyLCPPIIx4c+iyfZlVyOiDKLCTeXoEbE=";
  };

  metaCommon = {
@@ -50,7 +50,7 @@ let
        sourceRoot
        ;
      fetcherVersion = 2;
      hash = "sha256-gSgryNui5uXuJEKoojz+knZ8rlJpjaR2+XF3xTwV5YI=";
      hash = "sha256-MA0CNF2MTCGvsxvEpRbTFu5Diap4XkIHKnxeROkgwnU=";
    };

    buildPhase = ''
@@ -87,7 +87,7 @@ buildGoModule {
      --subst-var out
  '';

  vendorHash = "sha256-3kQWCjxCom/Sb4RzRF55NsDfSA9F9mOLy9sYVFUaevY=";
  vendorHash = "sha256-A39CVQTWMmOGa/XwM+cZQBsqINiN2UoUYC9voQTL7aU=";

  nativeBuildInputs = [
    autoPatchelfHook
+24 −23
Original line number Diff line number Diff line
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -41,13 +41,13 @@
 }
@@ -55,9 +55,14 @@ func CreateApp(fs embed.FS) *App {
 
 	app := NewApp()
 
 func CreateApp(fs embed.FS) *App {
-	exePath, err := os.Executable()
-	if err != nil {
-		panic(err)
+	Env.AppName = "GUI.for.SingBox"
+	xdgDataHome := os.Getenv("XDG_DATA_HOME")
+	if xdgDataHome == "" {
+		homeDir, _ := os.UserHomeDir()
+		xdgDataHome = filepath.Join(homeDir, ".local", "share")
-	if Env.OS == "darwin" {
-		createMacOSSymlink()
-		createMacOSMenus(app)
+	if Env.OS == "linux" || Env.OS == "darwin" {
+		userConfigDir, err := os.UserConfigDir()
+		if err == nil {
+			targetPath := filepath.Join(userConfigDir, Env.AppName)
+			if err := os.MkdirAll(targetPath, 0755); err == nil {
+				Env.BasePath = targetPath
+			}
+		}
 	}
-
-	Env.BasePath = filepath.Dir(exePath)
-	Env.AppName = filepath.Base(exePath)
+	Env.BasePath = filepath.Join(xdgDataHome, Env.AppName)
 
 	if slices.Contains(os.Args, "tasksch") {
 		Env.FromTaskSch = true
@@ -76,7 +76,7 @@
 	if Env.OS == "windows" {
@@ -80,7 +85,10 @@ func (a *App) IsStartup() bool {
 }
 
 func (a *App) RestartApp() FlagResult {
-	exePath := Env.BasePath + "/" + Env.AppName
+	exePath := "@basepath@/bin" + "/" + Env.AppName
+	exePath, err := os.Executable()
+	if err != nil {
+		exePath = filepath.Join(Env.BasePath, Env.AppName)
+	}
 
 	cmd := exec.Command(exePath)
 	SetCmdWindowHidden(cmd)