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

Linux: Follow the XDG Base Directory Specification #4337

Open
ruby0b opened this issue Dec 8, 2024 · 7 comments · May be fixed by #4347
Open

Linux: Follow the XDG Base Directory Specification #4337

ruby0b opened this issue Dec 8, 2024 · 7 comments · May be fixed by #4347
Assignees

Comments

@ruby0b
Copy link

ruby0b commented Dec 8, 2024

What feature would you like to see?

When using the AppImage on Linux, Archipelago creates ~/Archipelago to dump its files into:

Archipelago/Utils.py

Lines 154 to 156 in c9625e1

elif sys.platform.startswith('linux'):
home_path.cached_path = os.path.expanduser('~/Archipelago')
os.makedirs(home_path.cached_path, 0o700, exist_ok=True)

This behavior is annoying if you like to keep a clean home directory.
The XDG Base Directory Specification exists for this purpose and is widely followed on Linux nowadays.

Since Archipelago doesn't separate its files into clearly separatable directories, the recommended "catch-all" for cases like this is using $XDG_STATE_HOME (defaulting to ~/.local/state).

Therefore I propose using $XDG_STATE_HOME/Archipelago as the default Archipelago directory (moving ~/Archipelago to it if it exists):

    elif sys.platform.startswith('linux'): 
        xdg_state_home = os.getenv('XDG_STATE_HOME', os.path.expanduser('~/.local/state'))
        home_path.cached_path = xdg_state_home + '/Archipelago'
        if not os.path.isdir(home_path.cached_path):
            legacy_home_path = os.path.expanduser('~/Archipelago')
            if os.path.isdir(legacy_home_path):
                os.renames(legacy_home_path, home_path.cached_path)
            else:
                os.makedirs(home_path.cached_path, 0o700, exist_ok=True) 
@black-sliver
Copy link
Member

The problem is that ~/Archipelago/Players/ folder, which needs to be accessible, would then be in a hidden folder.

We need a solution for that before we can move stuff to a hidden folder.

@ruby0b
Copy link
Author

ruby0b commented Dec 8, 2024

The "Browse Files" button in the launcher already opens the correct folder, that should be discoverable enough, right?

I mean speaking as a user it's not really much more intuitive to look for a folder in your home directory when the AppImage you launched is in an entirely different location anyway.

@black-sliver
Copy link
Member

black-sliver commented Dec 8, 2024

Oh, yeah, it was late and I forgot that we already solved that.

(Setting up ~/Archipelago predates that button)

So there should be nothing in the way other than work. We should definitely include a migration code path, maybe create a symlink if the folder was moved so downgrading doesn't break.

@ruby0b
Copy link
Author

ruby0b commented Dec 9, 2024

Creating a symlink when moving sounds like a great idea, also has the benefit of possibly being less confusing to existing users :)

I'll create a PR (though I'm not familiar with the build process).

@black-sliver
Copy link
Member

I hope I get to this soon, I am wondering if state dir is correct though.

Looking at the XDG specs, it reads to me like if the data in that folder is important and/or portable (between versions?), it should be in XDG_DATA_HOME rather than XDG_STATE_HOME, which i think would apply to most files we put there.

though I'm not familiar with the build process

There is a github "Build" action that produces the build output. You just need to enable actions in the repo settings of your fork, go to actions tab, select "Build", and in the top right corner click "Run workflow" and select your branch.

@beauxq
Copy link
Collaborator

beauxq commented Dec 11, 2024

I'm imagining some users might prefer the ~/Archipelago folder (and not for it to be a link).
Is it something we can make configurable?

@black-sliver
Copy link
Member

The config is in that folder 🤔
Symlink is basically as good as a real folder for the purpose of quick access, no?
If they want to have it on a different mount point, they could create a symlink at $XDG_WHATEVER/Archipelago to that.

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 a pull request may close this issue.

3 participants