Also mentioned at (https://github.com/aditya-K2/gomp/issues/1#issuecomment-1205090265)

`~` is not expanded to home directory, Hence adding an internal check
for the same.
This commit is contained in:
aditya-K2
2022-09-12 23:16:24 +05:30
parent 6830b5379f
commit 29b796a552
2 changed files with 21 additions and 0 deletions

View File

@@ -29,15 +29,23 @@ var (
)
func ReadConfig() {
for k, v := range defaults {
viper.SetDefault(k, v)
}
viper.SetConfigName("config")
viper.AddConfigPath(HOME_DIR + "/.config/gomp")
err := viper.ReadInConfig()
if err != nil {
fmt.Println("Could Not Read Config file.")
}
// Expanding ~ to the User's Home Directory
viper.Set("MUSIC_DIRECTORY", utils.ExpandHomeDir(viper.GetString("MUSIC_DIRECTORY")))
viper.Set("DEFAULT_IMAGE_PATH", utils.ExpandHomeDir(viper.GetString("DEFAULT_IMAGE_PATH")))
viper.Set("CACHE_DIR", utils.ExpandHomeDir(viper.GetString("CACHE_DIR")))
}
func GenerateKeyMap(funcMap map[string]func()) {