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

[Feature] Follow XDG Base Directory specifications for bundled and additional user data on Linux #645

Closed
huantianad opened this issue Jul 22, 2023 · 1 comment · Fixed by #658
Assignees

Comments

@huantianad
Copy link

Is your feature request related to a problem? Please describe.
Currently, the application is expected to be run simply from somewhere in the user's home folder, and it includes bundled data, writes log files, and reads user songs and skins from the directory the binary is placed in. This works fine; however, it means that the application is not able to be installed systemwide, as say if the binary was placed at /bin/usc-game, it would be unable to write any files in the same directory (at /bin/) nor would it be ideal for the user to install songs in the /bin/ folder.

Describe the solution you'd like
The application should look in $XDG_DATA_DIRS (usually /usr/local/share/:/usr/share/) and $XDG_DATA_HOME (usually $HOME/.local/share) for data files in addition to directly next to the binary, in that order of priority. This will allow the program to install bundled files in /usr/share/usc-game/ and the user to install additional songs and skins in ~/.local/share/usc-game/, while keeping the binary at /bin/usc-game. Things like log files can be moved to $XDG_CACHE_HOME.

In addition, a CMake flag that would install the binary, .desktop file + icon, and bundled data files to the directory specified by the cmake install dir flags would be very helpful for building and packaging the program.

This should also ensure backwards compatibility with users of the previous setup, as the program would fallback to directly next to the binary if nothing exists at the other two locations ($XDG_DATA_DIRS, $XDG_DATA_HOME). If this does not work, perhaps the new folder structure can be only enabled with the above CMake flag, or a migration system can be put into place.

Describe alternatives you've considered
Tell users to cope and not install the game system-wide.

Additional context
I'm currently considering packaging this program as a part of nixpkgs, or just as a nix derivation for my own personal use, so I can easily update it and use it in my system without having to compile any updates. However, as a part of a nix package, the binary is stored in a read only enviornment, and thus the user can't add skins or songs next to the binary, and the binary can't write logs right next to itself, which is why I'd like this feature.

If this is something that you think could be feasible for me to implement in a PR, point me to the right place and I'll take a shot at it 😛. I'd also be cool with helping test this if need be.

@SkyLeite
Copy link

As a workaround, you can run the game with the -gamedir flag to specify where it should read those files from. You can take a look at how I did it for my (awful) Nix derivation: SkyLeite/NixMachines@83cae45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants