slgobinath/SafeEyes

Stop changing the safeeyes.json file

Closed this issue · 5 comments

Describe the bug

I think this is a bug but feel free to consider that as "feature request" if you prefer.

For me, files in ~/.config are my own: no application should modify them unless explicitly requested. This makes it possible to keep these files as small as possible, containing only what is different from the default. I would also like to order the attributes in the configuration file as I want and indent the file as I like it.

Currently, safeeyes:

  1. reindents the file systematically,
  2. replaces the whole content with some defaults if the "meta" attribute is not present or if the JSON is invalid
  3. reorders the attributes alphabetically

This behavior makes it impossible to use configuration-generation tools such as home-manager. These tool must keep the control of configuration files and shouldn't be responsible for writing default values for every existing configuration option.

To Reproduce
Steps to reproduce the behavior:

  1. Change the order of options in safeeyes.json so it is not alphabetical (or change indentation)
  2. Restart safeeyes
  3. Your file has changed

Expected behavior

  • if the configuration file is invalid, safeeyes should crash with a clear error message (e.g., "safeeyes.json is not a valid JSON document" or "the 'meta' attribute is mandatory and must have the value {"config_version": "6.0.3"}")
  • if the configuration file is valid, safeeyes shouldn't change it

Desktop (please complete the following information):

  • OS: Fedora 38
  • Window manager: i3wm
  • Version: 2.1.6

I understand your request thanks, and it makes sense. I now have a short time to work on this project, and would like to focus on 'serious' bugs that prevent SafeEyes being used at all.

Thank you for your response. Do you completely agree with the "Expected behavior" part? If you don't, it would be nice if you could find some time to explain your vision. This way, someone could do the job and open a PR.

I'm not the original developer I'm just an occasional developer trying to keep the project alive. I can offer an opinion, but that's just my personal one.

I understand your objective, and I partly agree. However:

  1. SafeEyes needs to write to the file when you save the settings or for a new config version. In this case it seems entirely reasonable that it would use a standard order and indentation.
  2. We don't need to be obsessive about config errors. If we can reasonably correct an error then we should. This is important to help a novice user who accidentally messed up their config.

I would agree that if the config file is valid (including the mandatory meta attribute), then SafeEyes shouldn't alter it on start-up.

NB Fixing the major bugs is the top priority. If you can help with that then great. Only after that would I start to look at feature requests.

Applications do modify .config to save their settings specific to your user. You back up/restore your .config files to restore settings for your apps.

If you want safeeyes to work with your arbitary changes in the json file, then please send a PR to implement their support.