Skip to content

feat: add XDG Base Directory support for config files#560

Open
EliteCracker wants to merge 1 commit intodvorka:masterfrom
EliteCracker:xdg-compliance
Open

feat: add XDG Base Directory support for config files#560
EliteCracker wants to merge 1 commit intodvorka:masterfrom
EliteCracker:xdg-compliance

Conversation

@EliteCracker
Copy link

Description

Adds support for the XDG Base Directory specification.

Changes

  • Configuration files (blacklist, favorites) now default to $XDG_CONFIG_HOME/hstr/ (usually ~/.config/hstr/).
  • Maintains backward compatibility: if ~/.hstr_favorites or ~/.hstr_blacklist exist, they are used instead of XDG paths.
  • Automatically creates the configuration directory structure if it doesn't exist.

Testing

Verified in a clean Arch Linux chroot:

  • Detected legacy files when present.
  • Created ~/.config/hstr/ when no legacy files existed.
  • Respected custom XDG_CONFIG_HOME environment variable.

Disclaimer

I did use Google Gemini 3 for assistance during this. I noticed this program had an old issue (#461), and I highly prefer a minimal $HOME. Therefore, I used the Arch Wiki to implement Gemini's changes, tested those changes, and here we are.

- Implemented get_hstr_configuration_file_path in hstr_utils to handle XDG resolution.
- Updated blacklist and favorites to use XDG_CONFIG_HOME/hstr/ or ~/.config/hstr/.
- Added legacy fallback to ~/.hstr_favorites and ~/.hstr_blacklist.
- Ensure config directories are created automatically.
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

Successfully merging this pull request may close these issues.

1 participant