nixpkgs/pkgs/by-name/gu/gui-for-clash/xdg-path-and-restart-patch.patch

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
789 B
Diff
Raw Permalink Normal View History

2025-08-11 10:10:50 +08:00
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
2025-05-13 07:54:25 +08:00
@@ -41,13 +41,13 @@
}
func CreateApp(fs embed.FS) *App {
2024-12-25 23:14:00 +08:00
- exePath, err := os.Executable()
- if err != nil {
- panic(err)
+ Env.AppName = "GUI.for.Clash"
+ xdgDataHome := os.Getenv("XDG_DATA_HOME")
+ if xdgDataHome == "" {
+ homeDir, _ := os.UserHomeDir()
+ xdgDataHome = filepath.Join(homeDir, ".local", "share")
2025-05-13 07:54:25 +08:00
}
-
- Env.BasePath = filepath.Dir(exePath)
- Env.AppName = filepath.Base(exePath)
2024-12-25 23:14:00 +08:00
+ Env.BasePath = filepath.Join(xdgDataHome, Env.AppName)
2025-05-13 07:54:25 +08:00
if slices.Contains(os.Args, "tasksch") {
Env.FromTaskSch = true
@@ -76,7 +76,7 @@
2024-12-25 23:14:00 +08:00
}
2025-05-13 07:54:25 +08:00
2024-12-25 23:14:00 +08:00
func (a *App) RestartApp() FlagResult {
- exePath := Env.BasePath + "/" + Env.AppName
2025-08-11 10:10:50 +08:00
+ exePath := "@out@/bin" + "/" + Env.AppName
2025-05-13 07:54:25 +08:00
2024-12-25 23:14:00 +08:00
cmd := exec.Command(exePath)
2025-08-11 10:10:50 +08:00
SetCmdWindowHidden(cmd)