Follow XDG Base Directory Specification on Linux/MacOS - #54
Merged
Merged
Conversation
If an existing $HOME/.sni directory is found use it Check for $XDG_CONFIG_HOME first and default to $HOME/.config/sni if unset
JamesDunne
requested changes
Apr 9, 2026
JamesDunne
left a comment
Contributor
There was a problem hiding this comment.
Looks good overall, just some minor formatting and rewording to clean up. Thanks a lot!
| On Windows, this folder is `%LOCALAPPDATA%\sni`. | ||
|
|
||
| On MacOS, this folder is `~/.sni/`. | ||
| On MacOS and Linux, this folder is `~/$XDG_CONFIG_HOME/sni/` or `~/.config/sni/` with `~/.sni/` as a fallback. |
Contributor
There was a problem hiding this comment.
Suggested change
| On MacOS and Linux, this folder is `~/$XDG_CONFIG_HOME/sni/` or `~/.config/sni/` with `~/.sni/` as a fallback. | |
| On MacOS and Linux, this folder is `$XDG_CONFIG_HOME/sni/` or `$HOME/.config/sni/` with `$HOME/.sni/` as a fallback. |
| var xdgConfig = os.Getenv("XDG_CONFIG_HOME") | ||
| if xdgConfig == "" { | ||
| homeDir, _ := os.UserHomeDir() | ||
| xdgConfig = filepath.Join(homeDir,".config") |
Contributor
There was a problem hiding this comment.
Suggested change
| xdgConfig = filepath.Join(homeDir,".config") | |
| xdgConfig = filepath.Join(homeDir, ".config") |
| homeDir, _ := os.UserHomeDir() | ||
| xdgConfig = filepath.Join(homeDir,".config") | ||
| } | ||
| Dir = filepath.Join(xdgConfig,"sni") |
Contributor
There was a problem hiding this comment.
Suggested change
| Dir = filepath.Join(xdgConfig,"sni") | |
| Dir = filepath.Join(xdgConfig, "sni") |
|
|
||
| On MacOS, this folder is `~/.sni/`. | ||
| On MacOS and Linux, this folder is `~/$XDG_CONFIG_HOME/sni/` or `~/.config/sni/` with `~/.sni/` as a fallback. | ||
| SNI use the following order when choosing a log folder : `~/.sni/` (if it already exist), `~/$XDG_CONFIG_HOME/sni/` if `$XDG_CONFIG_HOME` is not null,`~/.config/sni/` |
Contributor
There was a problem hiding this comment.
Suggested change
| SNI use the following order when choosing a log folder : `~/.sni/` (if it already exist), `~/$XDG_CONFIG_HOME/sni/` if `$XDG_CONFIG_HOME` is not null,`~/.config/sni/` | |
| SNI uses the following order when choosing a config folder: | |
| 1. `$HOME/.sni/` if it already exists | |
| 2. `$XDG_CONFIG_HOME/sni/` if `$XDG_CONFIG_HOME` is set (not empty) | |
| 3. `$HOME/.config/sni/` |
JamesDunne
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tested on Linux as I do not own a Mac but it should work.
This avoid creating a
.sniin the home directory by checkingXDG_CONFIG_HOMEfirst and defaulting to$HOME/.config/sniif it's not set.To avoid loosing configs and previous logs SNI will still use
$HOME/.sniif the directory already exist