klipper icon indicating copy to clipboard operation
klipper copied to clipboard

Use dotfiles for Klipper backup configuration

Open synthead opened this issue 10 months ago • 5 comments

This PR prepends a . to the name of the backup Klipper configuration file when SAVE_CONFIG is executed. This greatly de-clutters the Klipper configuration directory.

Here is an example of /etc/klipper after many SAVE_CONFIG calls. The backup files pollute the directory, and makes managing this directory difficult as a user.

$ ls /etc/klipper
klipper			     klipper-20250102_231643.cfg  klipper-20250108_201350.cfg  klipper-20250201_062042.cfg  klipper-20250204_092537.cfg
klipper-20241230_010002.cfg  klipper-20250102_232020.cfg  klipper-20250109_162625.cfg  klipper-20250201_063643.cfg  klipper-20250204_182142.cfg
klipper-20241230_011232.cfg  klipper-20250102_232556.cfg  klipper-20250109_172406.cfg  klipper-20250201_065344.cfg  klipper-20250204_183409.cfg
klipper-20241230_183238.cfg  klipper-20250102_235621.cfg  klipper-20250109_174713.cfg  klipper-20250201_071639.cfg  klipper-20250204_193018.cfg
klipper-20241230_184647.cfg  klipper-20250103_002034.cfg  klipper-20250111_133722.cfg  klipper-20250201_085324.cfg  klipper-20250204_194755.cfg
klipper-20241230_190858.cfg  klipper-20250103_233505.cfg  klipper-20250111_231710.cfg  klipper-20250201_085759.cfg  klipper-20250206_010314.cfg
klipper-20241230_193847.cfg  klipper-20250104_001433.cfg  klipper-20250112_002827.cfg  klipper-20250201_092728.cfg  klipper-20250206_010327.cfg
klipper-20241230_201524.cfg  klipper-20250104_003245.cfg  klipper-20250112_003101.cfg  klipper-20250201_094424.cfg  klipper-20250209_083342.cfg
klipper-20241230_201839.cfg  klipper-20250104_020937.cfg  klipper-20250120_215419.cfg  klipper-20250201_100913.cfg  klipper-20250209_085919.cfg
klipper-20241230_203903.cfg  klipper-20250105_181522.cfg  klipper-20250120_220518.cfg  klipper-20250202_082337.cfg  klipper-20250209_090526.cfg
klipper-20241231_144141.cfg  klipper-20250105_234452.cfg  klipper-20250121_220630.cfg  klipper-20250202_082927.cfg  klipper-20250209_093153.cfg
klipper-20241231_145323.cfg  klipper-20250106_135150.cfg  klipper-20250121_224252.cfg  klipper-20250202_085712.cfg  klipper-20250209_094548.cfg
klipper-20250101_191310.cfg  klipper-20250106_152108.cfg  klipper-20250131_133028.cfg  klipper-20250202_085929.cfg  klipper-20250209_101006.cfg
klipper-20250101_194524.cfg  klipper-20250106_233616.cfg  klipper-20250131_134838.cfg  klipper-20250202_090740.cfg  klipper-20250209_102219.cfg
klipper-20250101_233231.cfg  klipper-20250106_234352.cfg  klipper-20250201_025502.cfg  klipper-20250202_091204.cfg  klipper-20250210_010204.cfg
klipper-20250101_234316.cfg  klipper-20250107_112607.cfg  klipper-20250201_030006.cfg  klipper-20250202_092525.cfg  klipper.cfg
klipper-20250102_011046.cfg  klipper-20250107_145216.cfg  klipper-20250201_055142.cfg  klipper-20250203_000732.cfg  moonraker.conf
klipper-20250102_143420.cfg  klipper-20250107_160745.cfg  klipper-20250201_055731.cfg  klipper-20250203_045359.cfg
klipper-20250102_164936.cfg  klipper-20250107_161409.cfg  klipper-20250201_060051.cfg  klipper-20250203_050255.cfg
klipper-20250102_220506.cfg  klipper-20250108_020808.cfg  klipper-20250201_061048.cfg  klipper-20250204_082301.cfg
klipper-20250102_224536.cfg  klipper-20250108_153908.cfg  klipper-20250201_061547.cfg  klipper-20250204_085651.cfg

Here is what :point_up: would look like with the changes in this PR:

$ ls /etc/klipper
klipper  klipper.cfg  moonraker.conf

...and of course, the dotfiles can be viewed with -a, along with other dotfiles that carry a similar nature:

$ ls -a /etc/klipper
.			      .klipper-20250102_224536.cfg  .klipper-20250108_201350.cfg  .klipper-20250201_063643.cfg	.klipper-20250204_183409.cfg
..			      .klipper-20250102_231643.cfg  .klipper-20250109_162625.cfg  .klipper-20250201_065344.cfg	.klipper-20250204_193018.cfg
.git			      .klipper-20250102_232020.cfg  .klipper-20250109_172406.cfg  .klipper-20250201_071639.cfg	.klipper-20250204_194755.cfg
.klipper-20241230_010002.cfg  .klipper-20250102_232556.cfg  .klipper-20250109_174713.cfg  .klipper-20250201_085324.cfg	.klipper-20250206_010314.cfg
.klipper-20241230_011232.cfg  .klipper-20250102_235621.cfg  .klipper-20250111_133722.cfg  .klipper-20250201_085759.cfg	.klipper-20250206_010327.cfg
.klipper-20241230_183238.cfg  .klipper-20250103_002034.cfg  .klipper-20250111_231710.cfg  .klipper-20250201_092728.cfg	.klipper-20250209_083342.cfg
.klipper-20241230_184647.cfg  .klipper-20250103_233505.cfg  .klipper-20250112_002827.cfg  .klipper-20250201_094424.cfg	.klipper-20250209_085919.cfg
.klipper-20241230_190858.cfg  .klipper-20250104_001433.cfg  .klipper-20250112_003101.cfg  .klipper-20250201_100913.cfg	.klipper-20250209_090526.cfg
.klipper-20241230_193847.cfg  .klipper-20250104_003245.cfg  .klipper-20250120_215419.cfg  .klipper-20250202_082337.cfg	.klipper-20250209_093153.cfg
.klipper-20241230_201524.cfg  .klipper-20250104_020937.cfg  .klipper-20250120_220518.cfg  .klipper-20250202_082927.cfg	.klipper-20250209_094548.cfg
.klipper-20241230_201839.cfg  .klipper-20250105_181522.cfg  .klipper-20250121_220630.cfg  .klipper-20250202_085712.cfg	.klipper-20250209_101006.cfg
.klipper-20241230_203903.cfg  .klipper-20250105_234452.cfg  .klipper-20250121_224252.cfg  .klipper-20250202_085929.cfg	.klipper-20250209_102219.cfg
.klipper-20241231_144141.cfg  .klipper-20250106_135150.cfg  .klipper-20250131_133028.cfg  .klipper-20250202_090740.cfg	.klipper-20250210_010204.cfg
.klipper-20241231_145323.cfg  .klipper-20250106_152108.cfg  .klipper-20250131_134838.cfg  .klipper-20250202_091204.cfg	.klipper.cfg.un~
.klipper-20250101_191310.cfg  .klipper-20250106_233616.cfg  .klipper-20250201_025502.cfg  .klipper-20250202_092525.cfg	.moonraker.conf.bkp
.klipper-20250101_194524.cfg  .klipper-20250106_234352.cfg  .klipper-20250201_030006.cfg  .klipper-20250203_000732.cfg	klipper
.klipper-20250101_233231.cfg  .klipper-20250107_112607.cfg  .klipper-20250201_055142.cfg  .klipper-20250203_045359.cfg	klipper.cfg
.klipper-20250101_234316.cfg  .klipper-20250107_145216.cfg  .klipper-20250201_055731.cfg  .klipper-20250203_050255.cfg	moonraker.conf
.klipper-20250102_011046.cfg  .klipper-20250107_160745.cfg  .klipper-20250201_060051.cfg  .klipper-20250204_082301.cfg
.klipper-20250102_143420.cfg  .klipper-20250107_161409.cfg  .klipper-20250201_061048.cfg  .klipper-20250204_085651.cfg
.klipper-20250102_164936.cfg  .klipper-20250108_020808.cfg  .klipper-20250201_061547.cfg  .klipper-20250204_092537.cfg
.klipper-20250102_220506.cfg  .klipper-20250108_153908.cfg  .klipper-20250201_062042.cfg  .klipper-20250204_182142.cfg

synthead avatar Feb 10 '25 01:02 synthead

Thanks for the PR, but I personally think that it should not be changed:

  • It obfuscates the backups from the user, and most of them are not well-versed in Linux.
  • The popular web interfaces, Mainsail and Fluidd, already have an option to hide these backups, but the user has to do this intentionally and hopefully remembers it in case they are needed.

Sineos avatar Feb 10 '25 06:02 Sineos

I agree with @Sineos it makes them harder to find for the casual user, the front ends already deal with this in their directory listings and it would also need extra coding on the front end side to deal with to be able to show and hide them. Also this PR is not signed off, so will be not considered for inclusion in the first place, see point 3 in https://github.com/Klipper3d/klipper/blob/master/docs/CONTRIBUTING.md#what-to-expect-in-a-review

Thanks James

JamesH1978 avatar Feb 10 '25 10:02 JamesH1978

Hm, would you consider a config option to use dotfiles, or possibly accept an optional format? Dotfiles are very common, and I personally don't think that the consideration of quality should be dismissed because users don't know how to use Linux (or whatever Klipper is running on). I'm happy to make other contributions for compatibility, if desired.

Alternatively, we could also specify a backup config path in the configuration that would default to the current path. For users looking to keep the backups contained and out-of-view, they could choose to save them to .backup/ or something. If an optional format was supported, the path could also be a part of the format.

In addition to possibly hundreds of backup files visibly polluting the directory, my tab completion stops partway though klipper.cfg. When browsing my directory structure in Vim's file browser, the excess amount of files irrelevant to the current configuration makes selecting a file harder. Users may have these backups already hidden in the other Klipper software, but for those that are able to run ls on a command line will observe the clutter.

It'd be great to find a reasonable alternative approach! ❤️ I'm kind of tossing ideas at the wall; any thoughts?

synthead avatar Feb 11 '25 21:02 synthead

These files are only created on performing a SAVE_CONFIG process, so really dont run into the many for a normal user. I am not sure there are many situations where there would be hundreds.

I guess an arg for a config backup directory could be a thing, but in all my time in being a klipper user and being more involved in the project later on, i can't remember anyone complaining about a massive amount of backups, but thats not to say it isnt a thing at all.

I am also not sure sure what klipper.cfg actually is. Mainline klipper generally uses printer.cfg, also klipper does not tend to use the /etc/ directory either as it usually installed as the "normal" user and not a privileged one with access to /etc. I am guessing you have a fully custom setup of mainline klipper on a non-debian?

Thanks James

JamesH1978 avatar Feb 11 '25 23:02 JamesH1978

Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html

There are some steps that you can take now:

  1. Perform a self-review of your Pull Request by following the steps at: https://www.klipper3d.org/CONTRIBUTING.html#what-to-expect-in-a-review If you have completed a self-review, be sure to state the results of that self-review explicitly in the Pull Request comments. A reviewer is more likely to participate if the bulk of a review has already been completed.
  2. Consider opening a topic on the Klipper Discourse server to discuss this work. The Discourse server is a good place to discuss development ideas and to engage users interested in testing. Reviewers are more likely to prioritize Pull Requests with an active community of users.
  3. Consider helping out reviewers by reviewing other Klipper Pull Requests. Taking the time to perform a careful and detailed review of others work is appreciated. Regular contributors are more likely to prioritize the contributions of other regular contributors.

Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available.

Best regards, ~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being.

github-actions[bot] avatar Feb 26 '25 00:02 github-actions[bot]