mirror of
https://github.com/makew0rld/amfora.git
synced 2024-09-25 22:55:55 -04:00
✨ Prefer XDG vars if set - fixes #11
This commit is contained in:
parent
f0a75cf4a7
commit
199d122990
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Desktop entry file
|
- Desktop entry file
|
||||||
- Option to continue anyway when cert doesn't match TOFU database
|
- Option to continue anyway when cert doesn't match TOFU database
|
||||||
- Display all `text/*` documents, not just gemini and plain (#12)
|
- Display all `text/*` documents, not just gemini and plain (#12)
|
||||||
|
- Prefer XDG environment variables if they're set, to specify config dir, etc (#11)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Connection timeout is 15 seconds (was 5s)
|
- Connection timeout is 15 seconds (was 5s)
|
||||||
|
@ -67,7 +67,7 @@ Features in *italics* are in the master branch, but not in the latest release.
|
|||||||
- [ ] History browser
|
- [ ] History browser
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
The config file is written in the intuitive [TOML](https://github.com/toml-lang/toml) file format. See [default-config.toml](./default-config.toml) for details. By default this file is available at `~/.config/amfora/config.toml`.
|
The config file is written in the intuitive [TOML](https://github.com/toml-lang/toml) file format. See [default-config.toml](./default-config.toml) for details. By default this file is available at `~/.config/amfora/config.toml`, or `$XDG_CONFIG_HOME/amfora/config.toml`, if that variable is set.
|
||||||
|
|
||||||
On Windows, the file is in `%APPDATA%\amfora\config.toml`, which usually expands to `C:\Users\<username>\AppData\Roaming\amfora\config.toml`.
|
On Windows, the file is in `%APPDATA%\amfora\config.toml`, which usually expands to `C:\Users\<username>\AppData\Roaming\amfora\config.toml`.
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/makeworld-the-better-one/amfora/cache"
|
"github.com/makeworld-the-better-one/amfora/cache"
|
||||||
homedir "github.com/mitchellh/go-homedir"
|
homedir "github.com/mitchellh/go-homedir"
|
||||||
@ -37,17 +38,29 @@ func Init() error {
|
|||||||
configDir = amforaAppData
|
configDir = amforaAppData
|
||||||
} else {
|
} else {
|
||||||
// Unix / POSIX system
|
// Unix / POSIX system
|
||||||
configDir = filepath.Join(home, ".config", "amfora")
|
xdg_config, ok := os.LookupEnv("XDG_CONFIG_HOME")
|
||||||
|
if ok && strings.TrimSpace(xdg_config) != "" {
|
||||||
|
configDir = filepath.Join(xdg_config, "amfora")
|
||||||
|
} else {
|
||||||
|
// Default to ~/.config/amfora
|
||||||
|
configDir = filepath.Join(home, ".config", "amfora")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
configPath = filepath.Join(configDir, "config.toml")
|
configPath = filepath.Join(configDir, "config.toml")
|
||||||
|
|
||||||
// Cache TOFU db directory and file paths
|
// Cache TOFU db directory and file paths
|
||||||
// Windows just stores it in APPDATA along with other stuff
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
|
// Windows just stores it in APPDATA along with other stuff
|
||||||
tofuDBDir = amforaAppData
|
tofuDBDir = amforaAppData
|
||||||
} else {
|
} else {
|
||||||
// XDG cache dir on POSIX systems
|
// XDG cache dir on POSIX systems
|
||||||
tofuDBDir = filepath.Join(home, ".cache", "amfora")
|
xdg_cache, ok := os.LookupEnv("XDG_CACHE_HOME")
|
||||||
|
if ok && strings.TrimSpace(xdg_cache) != "" {
|
||||||
|
tofuDBDir = filepath.Join(xdg_cache, "amfora")
|
||||||
|
} else {
|
||||||
|
// Default to ~/.cache/amfora
|
||||||
|
tofuDBDir = filepath.Join(home, ".cache", "amfora")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tofuDBPath = filepath.Join(tofuDBDir, "tofu.toml")
|
tofuDBPath = filepath.Join(tofuDBDir, "tofu.toml")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user