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

Change configuration file location to ~/.config #24

Open
superjamie opened this issue Feb 11, 2023 · 1 comment
Open

Change configuration file location to ~/.config #24

superjamie opened this issue Feb 11, 2023 · 1 comment

Comments

@superjamie
Copy link

Thank you for your useful application. There's nothing quite like it. It's installed by default on many Linux distributions, so surely a great success too!

I hit the problem where the window could not be resized smaller and looked all through ~/.config and ~/.local for the config file. Finally I landed on #10. From that discussion:

#10 (comment)
the saved data file is in .cache rather than .config because it's not required; Magnus works without it. That makes it a cache, in my opinion; it can be safely removed at any time without a problem.

Please allow me to offer an alternative opinion.

A "cache" holds an identical copy of something which could be computationally re-generated identically at greater cost. It's a time-saving measure. Your CPU holds data in its cache to prevent fetching it from (slower) main memory or (very slow) disk. The thumbnail cache holds a small version of every image to prevent reading and resizing every large image file.

The only cost to deleting a cache is that the computer will take a little longer to perform some actions, as it must do those actions from scratch. However, the end result of the actions is always the same. No matter how many times I delete the thumbnail cache, the same image will re-generate the same thumbnail.

A "configuration" is a persistent user settting which overrides built-in defaults. It's perfectly normal for a program to operate without a configuration file, then the built-in defaults are used. However, if the program reads a file from disk which overrides the defaults, then this is a configuration file. The fact that a configuration file is not "required" for the program to start does not turn the configuration file into ephemeral cache content.

The cost to deleting a configuration is that the user's customisation of the program is lost, and the user must re-generate their settings again manually. Maybe that's something very easy (like roughly resizing a Magnus window) or maybe that's a very large time investment with the falliable human likely to forget some things. Imagine deleting your preferred code editor's configuration file!

In this situation, Magnus is storing settings which are then applied at new launch, and which override the default settings. This is a configuration so should logically go in ~/.config. Ideally it should actually go in $XDG_CONFIG_HOME as per the XDG Base Specification.

Please do consider changing the path. It would have saved me a lot of time to have the file in the expected location, and others on #10 by the sounds of it too.

@superjamie
Copy link
Author

If you're willing to accept, I'm happy to send a PR. It looks like just changing:

    def get_cache_file(self):
        return os.path.join(GLib.get_user_cache_dir(), "magnus.json")

To use get_user_config_dir instead:

    def get_cache_file(self):
        return os.path.join(GLib.get_user_config_dir(), "magnus.json")

Maybe that function could be renamed to get_config_file too.

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

No branches or pull requests

1 participant