-
Notifications
You must be signed in to change notification settings - Fork 8
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
introduce localization for Music dir on Linux #6
Conversation
Hi, If you don't mind changing up a couple details, I'd appreciate it, else I would do that.
Important: This pull request is even though I criticized it really valuable. Thanks you soooo much for that :3 (please excuse my inability to really know how this all works, this is my first experience with collaborations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this configuration file is not only related to localization. A user with the English local may still want to use a custom music folder.
I'd recommend you use pathlib instead of os.path
, as os.path
is more of a lower level utility than pathlib
, and in this case pathlib
makes more sense to me. But os.path
has already been used here.
I'd recommend placing all the code in this module in one or more functions, as this is executed on import (only the first one I think). Which is a bad practice, prone to bugs, and not necessarily what you want. But again, not in the scope of this PR as the problem was already there. However you could at least delete the global constant USER_XDG_DIR_FILE
, as its scope should not exist outside this module.
src/music_kraken/utils/shared.py
Outdated
|
||
|
||
USER_XDG_DIR_FILE = os.path.expanduser("~/.config/user-dirs.dirs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~/config
is default, but not standard, if you want to be XDG compliant, you should follow XDG_CONFIG_HOME
if set.
src/music_kraken/utils/shared.py
Outdated
|
||
|
||
USER_XDG_DIR_FILE = os.path.expanduser("~/.config/user-dirs.dirs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a system level fallback version of user-dirs.dirs
, located at /etc/xdg/user-dirs.defaults
. You should also read that one if the user one is not found. Note that it does not have to exist either.
Note that it is unclear to me what to do in the case both files exist, but only the system config file contains the value you want. I'd vote to use the system value if the user value does not override it, but you could also ignore the entire system config if the user config file exist.
Reference: https://www.freedesktop.org/wiki/Software/xdg-user-dirs/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say user-dirs.dirs is probably populated by most popular DE when setting up a new user with a language different than English.
On Arch, /etc/xdg/user-dirs.defaults
is a package required by the "plasma-desktop" meta package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey thanks again for this Pull request, but before I can accept and merge, it would be nice if you would implement @Kevin-Gruber 's suggested changes he commented. :)
@DistantThunder Are you still working on it, or will you don't implement those requestet changes? I just would need to know that. Thanks in advance and have a pleasant day :) |
Hi, I just haven't had time. If you want to proceed without waiting, there's no problem. |
Thank you for the reply. Because it is no urgent feature whatsoever, I will wait for you to finish it. If I refactored that part of the code I will still copy paste you're work in there. So you wont do any work for nothing and I am gonna use it no matter how many merge conflicts occur. (less would be best but yea if required copy paste is gonna do the job) :) |
Those changes has been pushed. @Kevin-Gruber suggestions are incredibly valuable, but may need their own PR? |
Hey thank you to both of you. This looks very good so far! Please look over the comment I wrote, regarding the fallback to Have a pleasant day ^^ |
Yeah sorry, don't even remember why I changed that (I'm bad at code). It should be ok now? |
@DistantThunder @Kevin-Gruber thank you so much. The code should be ready to merge (at least I am merging it). @DistantThunder You are not bad at code. If it works it works. You submitted good code, "even" you're initial code was far from stuff a beginner would write. Thank you. @Kevin-Gruber Thank you for you're helpful revies, else there would have been some issues in the future. If you want to change this code (or some other piece of code), feel free to create a pull request yourself. I'd appreciate it, but you don't have to. Also the feedback you gave me about just putting the code in this file have been heard, and I will change it once I add a config. Currently I am still refactoring the database ^^ Thanks :) |
This fixes the program not being able to find localized Music directories on XDG Linux systems