Since 19fc20c , a new htop_history file is introduced for recording history of search queries. However, it might not the most ideal location for storing the history file next to htoprc (wherever the htoprc file is located).
The XDG Base Directory Specification (0.8) has specified a $XDG_STATE_HOME directory, which I could argue would be a better location. Unfortunately the spec from XDG is vague. I'm not sure it was intended to store what's analogous to /var/log but for user files. Anyway, this issue report is to encourage discussion about using $XDG_STATE_HOME for the thing.
To be precise, I suggest if the $XDG_STATE_HOME is to be used, then
- the history file should be stored as
$XDG_STATE_HOME/htop/htop_history (fallback to $HOME/.local/state/htop/htop_history if the $XDG_STATE_HOME variable is undefined);
- for backward compatibility, the
$XDG_CONFIG_HOME/htop/htop_history might still be read, but $XDG_STATE_HOME/htop/htop_history would take precedence if it exists.
P.S. About the reason of separating $XDG_CONFIG_HOME and $XDG_STATE_HOME:
This is my personal understanding, and not written within the XDG spec. The Unix systems usually separate configuration files and variable files into different directories (see the Filesystem Hierarchy Standard), /etc and /var respectively. The assumption was that application might frequently update the files in /var but would only update files in /etc when there is a setting change system-wide. /etc could be mounted read-only by administrators if they don't intend to change the settings throughout the applications' runtime, but /var should be writable unless there's a special need. That justified the separation of the config directory and the state directory.
Since 19fc20c , a new
htop_historyfile is introduced for recording history of search queries. However, it might not the most ideal location for storing the history file next tohtoprc(wherever thehtoprcfile is located).The XDG Base Directory Specification (0.8) has specified a
$XDG_STATE_HOMEdirectory, which I could argue would be a better location. Unfortunately the spec from XDG is vague. I'm not sure it was intended to store what's analogous to/var/logbut for user files. Anyway, this issue report is to encourage discussion about using$XDG_STATE_HOMEfor the thing.To be precise, I suggest if the
$XDG_STATE_HOMEis to be used, then$XDG_STATE_HOME/htop/htop_history(fallback to$HOME/.local/state/htop/htop_historyif the$XDG_STATE_HOMEvariable is undefined);$XDG_CONFIG_HOME/htop/htop_historymight still be read, but$XDG_STATE_HOME/htop/htop_historywould take precedence if it exists.P.S. About the reason of separating
$XDG_CONFIG_HOMEand$XDG_STATE_HOME:This is my personal understanding, and not written within the XDG spec. The Unix systems usually separate configuration files and variable files into different directories (see the Filesystem Hierarchy Standard),
/etcand/varrespectively. The assumption was that application might frequently update the files in/varbut would only update files in/etcwhen there is a setting change system-wide./etccould be mounted read-only by administrators if they don't intend to change the settings throughout the applications' runtime, but/varshould be writable unless there's a special need. That justified the separation of the config directory and the state directory.