Skip to content

[fix] Change to $XDG_DATA_HOME instead of $HOME #74

@Sarthak-Bhagat

Description

@Sarthak-Bhagat

Hi, I'm switching from Trakt to Simkl and came across this project. Thanks for making it.

While setting up the scrobbler on Linux, I noticed that the application is saving the access token at:

$HOME/kavinthangavel/simkl-mps/

According to the documentation, the expected location is:

~/.local/share/kavinthangavel/simkl-mps/

Here’s snippets from the simkl-scrobbler init log showing the behavior(lmk if you want screenshots):

[*] Using Access Token file: /home/[ME]/kavinthangavel/simkl-scrobbler/.simkl_scrobbler.env
[*] Saving new access token to: /home/[ME]/kavinthangavel/simkl-scrobbler/.simkl_scrobbler.env

Root cause

From a cursory look at your code I noticed that in config_manager.py, the data directory is currently defined as:

APP_DATA_DIR = Path.home() / USER_SUBDIR / APP_NAME

Path.home() is the equivalent of $HOME on linux, not ~/.local/share. I might be wrong though, because afaik the above code would result in your app data going to %USERPROFILE% instead of %APPDATA%, and a Windows user should have noticed that by now. Not sure about MacOS.

Recommendation

Instead of using Path.home() I recommend using the platformdirs library (or implementing a similar function).

from platformdirs import user_data_dir

DATA_HOME = Path(user_data_dir)
APP_DATA_DIR = DATA_HOME / USER_SUBDIR / APP_NAME

I understand this might be a very low priority issue, but just want to point it out because my OCD is driving me insane because of the data folder in my $HOME. Also, you're basically lying about being XDG Base Directory Specification compliant right now which is a bad look for any app.

Happy to help test or contribute a patch if needed. Thanks again.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions