Skip to content

Commit

Permalink
Merge pull request #97 from adrg/macos-additional-search-paths
Browse files Browse the repository at this point in the history
Add more data and config search paths on macOS
  • Loading branch information
adrg authored Oct 15, 2024
2 parents 0d710b1 + 1d38818 commit 1409556
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ Sensible fallback locations are used for the folders which are not set.
<summary><strong>Unix-like operating systems</strong></summary>
<br/>

| <a href="#xdg-base-directory"><img width="400" height="0"></a> | <a href="#xdg-base-directory"><img width="500" height="0"></a><p>Unix</p> | <a href="#xdg-base-directory"><img width="600" height="0"></a><p>macOS</p> | <a href="#xdg-base-directory"><img width="500" height="0"></a><p>Plan 9</p> |
| :------------------------------------------------------------: | :-----------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------: |
| <kbd><b>XDG_DATA_HOME</b></kbd> | <kbd>~/.local/share</kbd> | <kbd>~/Library/Application&nbsp;Support</kbd> | <kbd>$home/lib</kbd> |
| <kbd><b>XDG_DATA_DIRS</b></kbd> | <kbd>/usr/local/share</kbd><br/><kbd>/usr/share</kbd> | <kbd>/Library/Application&nbsp;Support</kbd> | <kbd>/lib</kbd> |
| <kbd><b>XDG_CONFIG_HOME</b></kbd> | <kbd>~/.config</kbd> | <kbd>~/Library/Application&nbsp;Support</kbd> | <kbd>$home/lib</kbd> |
| <kbd><b>XDG_CONFIG_DIRS</b></kbd> | <kbd>/etc/xdg</kbd> | <kbd>~/Library/Preferences</kbd><br/><kbd>/Library/Application&nbsp;Support</kbd><br/><kbd>/Library/Preferences</kbd> | <kbd>/lib</kbd> |
| <kbd><b>XDG_STATE_HOME</b></kbd> | <kbd>~/.local/state</kbd> | <kbd>~/Library/Application&nbsp;Support</kbd> | <kbd>$home/lib/state</kbd> |
| <kbd><b>XDG_CACHE_HOME</b></kbd> | <kbd>~/.cache</kbd> | <kbd>~/Library/Caches</kbd> | <kbd>$home/lib/cache</kbd> |
| <kbd><b>XDG_RUNTIME_DIR</b></kbd> | <kbd>/run/user/UID</kbd> | <kbd>~/Library/Application&nbsp;Support</kbd> | <kbd>/tmp</kbd> |
| <kbd><b>XDG_BIN_HOME</b></kbd> | <kbd>~/.local/bin</kbd> | <kbd>~/.local/bin</kbd> | <kbd>$home/bin</kbd> |
| <a href="#xdg-base-directory"><img width="400" height="0"></a> | <a href="#xdg-base-directory"><img width="500" height="0"></a><p>Unix</p> | <a href="#xdg-base-directory"><img width="600" height="0"></a><p>macOS</p> | <a href="#xdg-base-directory"><img width="500" height="0"></a><p>Plan 9</p> |
| :------------------------------------------------------------: | :-----------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------: |
| <kbd><b>XDG_DATA_HOME</b></kbd> | <kbd>~/.local/share</kbd> | <kbd>~/Library/Application&nbsp;Support</kbd> | <kbd>$home/lib</kbd> |
| <kbd><b>XDG_DATA_DIRS</b></kbd> | <kbd>/usr/local/share</kbd><br/><kbd>/usr/share</kbd> | <kbd>/Library/Application&nbsp;Support</kbd><kbd>~/.local/share</kbd> | <kbd>/lib</kbd> |
| <kbd><b>XDG_CONFIG_HOME</b></kbd> | <kbd>~/.config</kbd> | <kbd>~/Library/Application&nbsp;Support</kbd> | <kbd>$home/lib</kbd> |
| <kbd><b>XDG_CONFIG_DIRS</b></kbd> | <kbd>/etc/xdg</kbd> | <kbd>~/Library/Preferences</kbd><br/><kbd>/Library/Application&nbsp;Support</kbd><br/><kbd>/Library/Preferences</kbd><br/><kbd>&#126;/.config</kbd> | <kbd>/lib</kbd> |
| <kbd><b>XDG_STATE_HOME</b></kbd> | <kbd>~/.local/state</kbd> | <kbd>~/Library/Application&nbsp;Support</kbd> | <kbd>$home/lib/state</kbd> |
| <kbd><b>XDG_CACHE_HOME</b></kbd> | <kbd>~/.cache</kbd> | <kbd>~/Library/Caches</kbd> | <kbd>$home/lib/cache</kbd> |
| <kbd><b>XDG_RUNTIME_DIR</b></kbd> | <kbd>/run/user/UID</kbd> | <kbd>~/Library/Application&nbsp;Support</kbd> | <kbd>/tmp</kbd> |
| <kbd><b>XDG_BIN_HOME</b></kbd> | <kbd>~/.local/bin</kbd> | <kbd>~/.local/bin</kbd> | <kbd>$home/bin</kbd> |

</details>

Expand Down
6 changes: 5 additions & 1 deletion paths_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ func initBaseDirs(home string) {

// Initialize standard directories.
baseDirs.dataHome = pathutil.EnvPath(envDataHome, homeAppSupport)
baseDirs.data = pathutil.EnvPathList(envDataDirs, rootAppSupport)
baseDirs.data = pathutil.EnvPathList(envDataDirs,
rootAppSupport,
filepath.Join(home, ".local", "share"),
)
baseDirs.configHome = pathutil.EnvPath(envConfigHome, homeAppSupport)
baseDirs.config = pathutil.EnvPathList(envConfigDirs,
filepath.Join(home, "Library", "Preferences"),
rootAppSupport,
"/Library/Preferences",
filepath.Join(home, ".config"),
)
baseDirs.stateHome = pathutil.EnvPath(envStateHome, homeAppSupport)
baseDirs.cacheHome = pathutil.EnvPath(envCacheHome, filepath.Join(home, "Library", "Caches"))
Expand Down
10 changes: 7 additions & 3 deletions paths_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ func TestDefaultBaseDirs(t *testing.T) {
actual: &xdg.DataHome,
},
&envSample{
name: "XDG_DATA_DIRS",
expected: []string{rootAppSupport},
actual: &xdg.DataDirs,
name: "XDG_DATA_DIRS",
expected: []string{
rootAppSupport,
filepath.Join(home, ".local", "share"),
},
actual: &xdg.DataDirs,
},
&envSample{
name: "XDG_CONFIG_HOME",
Expand All @@ -38,6 +41,7 @@ func TestDefaultBaseDirs(t *testing.T) {
filepath.Join(home, "Library", "Preferences"),
rootAppSupport,
"/Library/Preferences",
filepath.Join(home, ".config"),
},
actual: &xdg.ConfigDirs,
},
Expand Down

0 comments on commit 1409556

Please sign in to comment.