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

Request: improve conformance with the XDG Base Directory Specification #2004

Open
jwatt opened this issue Jan 23, 2021 · 5 comments
Open

Request: improve conformance with the XDG Base Directory Specification #2004

jwatt opened this issue Jan 23, 2021 · 5 comments

Comments

@jwatt
Copy link

jwatt commented Jan 23, 2021

micro appears to create the file ~/.config/micro/buffers/history, which is not a configuration file. Data generated from the use of an app should be put under ${XDG_DATA_HOME:-~/.local/share}, so it seems like the buffers directory should live at ${XDG_DATA_HOME:-~/.local/share/micro/buffers}. Would you mind updating micro to use that path?

Many thanks for micro, it's awesome. 😄

Commit hash: cfcb2e4
OS: Fedora 33
Terminal: Konsole/bash

@0x5c
Copy link
Contributor

0x5c commented Mar 2, 2021

This would be great, especially with config/dotfile management systems. With the current behaviour, it's impossible to just track ~/.config/micro/, one has to individually track each config files (settings.json, bindings.json, colorschemes/, etc).

There is already an option to use a custom directory for backups, so this could be implemented similarly for the other things.

@adrianinsaval
Copy link

Also ~/.config/micro/backups should probably be on ~/.cache/micro/backups instead

@0x5c
Copy link
Contributor

0x5c commented Jun 27, 2022

Either of data home (.local/share) or state home (.local/state) would seem more appropriate for the backups, especially state since it is defined in the spec at the place for command history, undo history, etc
The current version of the spec is here

@da2x
Copy link

da2x commented Aug 7, 2022

Also ~/.config/micro/backups should probably be on ~/.cache/micro/backups instead

The ./backup/* directory is configurable (backupdir). However, it does belong in the $XDG_CACHE_HOME directory rather than $XDG_CONFIG_HOME as-is the current default.

The ./buffers/history file belongs in the $XDG_STATE_HOME/micro/ directory.

The ./buffers/* directory belongs in the $XDG_CACHE_HOME/micro/ directory. (It, arguably, belongs in $XDG_STATE_HOME/micro/ when the savecursor option is enabled (off by default). However, overall it’s closer to cache data than state data.)


#3 Migration strategy

Option A:

  1. Check if the lastmigration option in the in settings.json file.
    1. If not present or matches a version number lower than the current version number:
      1. Move the ${XDG_CONFIG_HOME:-$HOME/.config}/micro/buffers/history file to ${XDG_STATE_HOME:-$HOME/.local/state}/micro/history. (Skip if the source file doesn’t already exist.)
      2. Move the ${XDG_CONFIG_HOME:-$HOME/.config}/micro/buffers/ directory to ${XDG_CACHE_HOME:-$HOME/.cache}/micro/buffers/. (Skip if the source directory doesn’t already exist.)
      3. Move the ${XDG_CONFIG_HOME:-$HOME/.config}/micro/backups/ directory to ${XDG_CACHE_HOME:-$HOME/.cache}/micro/buffers/. (Skip if the source directory doesn’t already exist.)
      4. Add "lastmigration": $current_version_number to the settings file.
    2. If present and equal to the current or a higher version number, then abort.

Option B:

Just leave the old files in their current location and begin using the new locations. You’ll still likely get 99.8 % user-satisfaction.


Alternative approaches

  1. Leave the ./buffers and ./backup directories inside $XDG_CONFIG_HOME. When these folders are created (no migration strategy), mark them as cachy/trashy directories. Automatically add a CACHEDIR.TAG file into each directory. Also, set the extended attributes com.apple.metadata:com_apple_backup_excludeItem with a value of [empty] (MacOS) and xdg.robots.backup with a value of false (Linux) on each directory. Lots of backup and search utilities will know to ignore them by default. There’s nothing equivalent on Windows.
  2. Add buffersdir and historyfile configuration options but leave the current defaults (or take the opportunity to adjust their defaults with the implementation of these options).

@clipcarl
Copy link

I've submitted a patch (and a link to a Linux test binary) in #3185.

injust added a commit to injust/dotfiles that referenced this issue Jul 13, 2024
injust added a commit to injust/dotfiles that referenced this issue Jul 13, 2024
injust added a commit to injust/dotfiles that referenced this issue Jul 13, 2024
injust added a commit to injust/dotfiles that referenced this issue Jul 13, 2024
injust added a commit to injust/dotfiles that referenced this issue Jul 13, 2024
injust added a commit to injust/dotfiles that referenced this issue Jul 13, 2024
injust added a commit to injust/dotfiles that referenced this issue Jul 14, 2024
injust added a commit to injust/dotfiles that referenced this issue Jul 14, 2024
injust added a commit to injust/dotfiles that referenced this issue Jul 16, 2024
injust added a commit to injust/dotfiles that referenced this issue Jul 18, 2024
injust added a commit to injust/dotfiles that referenced this issue Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants