From 1be64ef75100dd1ae4f246911e30cdb324db4f8a Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 23 Oct 2024 10:37:46 -0600 Subject: 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 Acked-by: Robin Jarry --- lib/xdg/xdg.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib') 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()) -- cgit