diff options
author | Tristan Partin <tristan@partin.io> | 2024-10-23 10:37:46 -0600 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-10-24 22:13:51 +0200 |
commit | 1be64ef75100dd1ae4f246911e30cdb324db4f8a (patch) | |
tree | 8537da2b7e6c4c31069e3eb46d00dae8a28e11ad /lib/xdg | |
parent | d0484b153aa5fa80c415f4025aef493eba167e12 (diff) | |
download | aerc-1be64ef75100dd1ae4f246911e30cdb324db4f8a.tar.gz |
history: read the history file from XDG_STATE_HOME
History is more like application state than a cache you would just want
to blow away. Let's reflect that in the path for the history file.
Changelog-changed: The location of the command history file has
changed to ${XDG_STATE_HOME:-$HOME/.local/state}/aerc/history.
Signed-off-by: Tristan Partin <tristan@partin.io>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/xdg')
-rw-r--r-- | lib/xdg/xdg.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/xdg/xdg.go b/lib/xdg/xdg.go index 6060c2bc..0c578fad 100644 --- a/lib/xdg/xdg.go +++ b/lib/xdg/xdg.go @@ -67,6 +67,19 @@ func DataPath(paths ...string) string { return res } +// Return a path relative to the user state home dir +func StatePath(paths ...string) string { + res := filepath.Join(paths...) + if !filepath.IsAbs(res) { + data := os.Getenv("XDG_STATE_HOME") + if data == "" { + data = ExpandHome("~/.local/state") + } + res = filepath.Join(data, res) + } + return res +} + // ugly: there's no other way to allow mocking a function in go... var userRuntimePath = func() string { uid := strconv.Itoa(os.Getuid()) |