From 8d40576c6526d6f180c96fbeb81d7f59f56b51b8 Mon Sep 17 00:00:00 2001 From: Gareth Date: Thu, 7 Dec 2023 18:10:58 -0800 Subject: [PATCH] fix: unexpected config location on MacOS --- internal/config/environment.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/config/environment.go b/internal/config/environment.go index ccd3faee..40590caf 100644 --- a/internal/config/environment.go +++ b/internal/config/environment.go @@ -22,7 +22,6 @@ func ConfigFilePath() string { if val := os.Getenv(EnvVarConfigPath); val != "" { return val } - return path.Join(getConfigDir(), "resticui/config.json") } @@ -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") }