Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for $XDG_STATE_HOME #2106

Closed
wants to merge 4 commits into from
Closed

Conversation

62832
Copy link
Contributor

@62832 62832 commented Apr 8, 2024

The most recent version of the XDG Base Directory Specification from 2021 introduces the new $XDG_STATE_HOME directory for non-essential "state" data such as history and logs.

The $XDG_STATE_HOME contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME. It may contain:

  • actions history (logs, history, recently used files, …)
  • current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

This PR adds support for this directory via the weechat_state_dir property, and uses this directory by default from now on to store log files. Closes #1747.

@flashcode
Copy link
Member

Hi,

Thanks for this PR.

There's a discussion about what to move to the XDG state directory in this issue: #1747.
And I concur with @trygveaa about the fact that buffer log files (from logger plugin) are important and just not "state", and should stay in data directory.

The specification is not very clear about what should be moved anyway.

Any thoughts from other people?

@flashcode flashcode added the feature New feature request label Apr 8, 2024
@flashcode flashcode self-assigned this Apr 8, 2024
@62832
Copy link
Contributor Author

62832 commented Apr 8, 2024

buffer log files (from logger plugin) are important and just not "state", and should stay in data directory.

No problem, the default for those can simply be changed back to ${weechat_data_dir} instead then. Although, I would personally argue that even if the log files aren't overwritten, then much like a history file, they really ought to be considered "state".

@flashcode
Copy link
Member

By the way I'm not even sure if the weechat.log file should be in $XDG_STATE_HOME or $XDG_RUNTIME_DIR directory, as it's a temporary log file used for lock (it's used to prevent two weechat instances to use the same home directory).

@62832
Copy link
Contributor Author

62832 commented Apr 8, 2024

Considering that weechat.log doesn't remove itself upon exit like a regular "lock" file would, I would treat it as a regular log file for $XDG_STATE_HOME.

flashcode added a commit that referenced this pull request Apr 12, 2024
@flashcode
Copy link
Member

Thanks, I squashed commits and merged without the changes in logger plugin.

@flashcode flashcode closed this Apr 12, 2024
@flashcode flashcode added this to the 4.3.0 milestone Apr 12, 2024
flashcode added a commit that referenced this pull request Apr 28, 2024
When 4 directories are received, the state directory is initialized with the
data directory.

This fixes the following error on `/upgrade`:

Error: wrong number of paths for home directories (expected: 1 or 5, received: 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for $XDG_STATE_HOME
2 participants