Skip to content

Commit

Permalink
fix: unexpected config location on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Dec 8, 2023
1 parent 253ccb4 commit 8d40576
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions internal/config/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func ConfigFilePath() string {
if val := os.Getenv(EnvVarConfigPath); val != "" {
return val
}

return path.Join(getConfigDir(), "resticui/config.json")
}

Expand Down Expand Up @@ -69,9 +68,15 @@ func getHomeDir() string {
}

func getConfigDir() string {
cfgDir, err := os.UserConfigDir()
if err != nil {
panic(fmt.Errorf("couldn't determine config directory: %v", err))
if runtime.GOOS == "windows" {
cfgDir, err := os.UserConfigDir()
if err != nil {
panic(fmt.Errorf("couldn't determine config directory: %v", err))
}
return cfgDir
}
if val := os.Getenv("XDG_CONFIG_HOME"); val != "" {
return val
}
return cfgDir
return path.Join(getHomeDir(), ".config")
}

0 comments on commit 8d40576

Please sign in to comment.