Skip to content

htop_history storage location and $XDG_STATE_HOME #1944

@Explorer09

Description

@Explorer09

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

  1. 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);
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions