config: expand tilde in search directories
Will expand a user-provided custom sharedir, XDG_CONFIG_HOME and XDG_DATA_HOME if necessary. Will not alter those strings if they do not begin with a tilde. Signed-off-by: Daniel Patterson <me@danielpatterson.dev> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
0cfffaef54
commit
c77a1c5d9d
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/go-ini/ini"
|
||||
"github.com/imdario/mergo"
|
||||
"github.com/kyoh86/xdg"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
|
||||
"git.sr.ht/~rjarry/aerc/lib/templates"
|
||||
)
|
||||
|
@ -311,13 +312,20 @@ func buildDefaultDirs() []string {
|
|||
// Add XDG_CONFIG_HOME and XDG_DATA_HOME
|
||||
for _, v := range prefixes {
|
||||
if v != "" {
|
||||
v, err := homedir.Expand(v)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
defaultDirs = append(defaultDirs, path.Join(v, "aerc"))
|
||||
}
|
||||
}
|
||||
|
||||
// Add custom buildtime shareDir
|
||||
if shareDir != "" && shareDir != "/usr/local/share/aerc" {
|
||||
defaultDirs = append(defaultDirs, shareDir)
|
||||
shareDir, err := homedir.Expand(shareDir)
|
||||
if err == nil {
|
||||
defaultDirs = append(defaultDirs, shareDir)
|
||||
}
|
||||
}
|
||||
|
||||
// Add fixed fallback locations
|
||||
|
|
Loading…
Reference in New Issue