Use OS-specific config directory to store config file

This commit is contained in:
ayntgl 2021-10-14 15:48:14 +04:00
parent 4ab256ecb7
commit a1f1a258bb
2 changed files with 3 additions and 3 deletions

View file

@ -36,7 +36,7 @@ sudo mv ./discordo /usr/local/bin
## Usage
1. Run the `discordo` executable with no arguments. A new and default configuration will be created at `~/.config/discordo.toml` on first startup.
1. Run the `discordo` executable with no arguments. On first startup, a default configuration file will be created at `$HOME/.config/discordo.toml` on Unix, `%AppData%/discordo.toml` on Windows, `$HOME/Library/Application Support/discordo.toml` on Darwin, and `$home/lib/discordo.toml` on Plan 9.
2. Log in using the account email and password (first-time login) and click on the "Login" button to continue.
> By default, Discordo utilizes OS-specific keyring to store credentials such as client authentication token. However, if you prefer not to use a keyring (not recommended), you may set the `token` field in the configuration file and Discordo will prioritize the usage of the provided token to login instead of keyring.

View file

@ -77,12 +77,12 @@ type config struct {
}
func loadConfig() *config {
u, err := os.UserHomeDir()
configPath, err := os.UserConfigDir()
if err != nil {
panic(err)
}
configPath := u + "/.config/discordo.toml"
configPath = configPath + "/discordo.toml"
if _, err = os.Stat(configPath); os.IsNotExist(err) {
f, err := os.Create(configPath)
if err != nil {