-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Support XDG user directories #5333
Conversation
This can be used to receive configuration for "well known" directories directly from the user. In our case, only the music directory really matters. It's possible to implement some kind of caching system here so that the same file doesn't get cached multiple times, but it's only used from a single location ('beets.Library.__init__'), so it doesn't seem to be really necessary.
Fixes beetbox#5168. Beets will now look for a music directory as follows: 1. Configuration in 'config.yaml'. 2. On Unix-like systems, 'XDG_MUSIC_DIR' in 'user-dirs.dirs'. 3. The fallback '~/Music'.
This allows testing the lookup and parsing stages independently.
I'm not great at writing tests, but this is a good start.
I don't love writing (example-based) tests, so there aren't many right now. If you'd like to see some more, let me know. |
Have you considered using platformdirs? |
Oh shoot, I hadn't realized that was a thing. I had searched around PyPi for XDG related libraries, but this one hadn't come up for some reason. I think it's best for me to close this PR and open a new one which just uses |
Yeah I remember it took me a while to discover it exists as well! Sounds like a good approach. |
I'll close this, as you suggested @bal-e |
Description
Fixes #5168. A simple parser for
user-dirs.dirs
has been implemented, and it is used to change the default music directory path whenbeets.Library
is initialized.To Do
Documentation