Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

Have --restore argument actually restore the saved config#62

Merged
anufrievroman merged 2 commits intoanufrievroman:mainfrom
jjramsey:main
Jul 9, 2024
Merged

Have --restore argument actually restore the saved config#62
anufrievroman merged 2 commits intoanufrievroman:mainfrom
jjramsey:main

Conversation

@jjramsey
Copy link
Contributor

@jjramsey jjramsey commented Jul 4, 2024

I was annoyed when waypaper --restore only restored the image but not the settings used to display the image stored in config.ini, so I decided to fix that. That probably fits better with the expectations of what --restore is supposed to do.

@anufrievroman
Copy link
Owner

I'm not really sure why that would fix it (or why there would be a problem in the first place) because the config and all the values are read much earlier when cf = Config(), because read() is part of the init of the config class.

@jjramsey
Copy link
Contributor Author

jjramsey commented Jul 9, 2024

Well, I just tried the original version of waypaper, and the bug is still there, and I tried my version of the package, and it fixes that problem.

One thing I found out from a python REPL section is that it takes two executions of the read() method to get it to read the INI file correctly.

>>> import waypaper.__main__
>>> print(waypaper.__main__.cf.config_file)
/home/jjramsey/.config/waypaper/config.ini
>>> print(waypaper.__main__.cf.fill_option)
fill
>>> waypaper.__main__.cf.read()
>>> print(waypaper.__main__.cf.fill_option)
Fit

The "Fit" option is what's in my config.ini file.

I don't understand it either, and I didn't realize that problem until today. Really bizarre, and it has me stumped.

@jjramsey
Copy link
Contributor Author

jjramsey commented Jul 9, 2024

I figured it out. The problem was that the config.ini file was written incorrectly by the Waypaper GUI. It took the result from the combo box for the fill option, but left it capitalized. When the check_validity() method was invoked when the __init__() method for the Config class was run, it saw the incorrectly written fill option and replaced it with its default. Hence, "Fit" was replaced with "fill".

When I read the config file the second time in the previous version of my pull request, check_validity() wasn't rerun, so the fill option didn't reset. That's why it "worked."

@anufrievroman
Copy link
Owner

Ah, I see, I don't know how nobody ever noticed that before 😅 Thank you!

@anufrievroman anufrievroman merged commit 78de112 into anufrievroman:main Jul 9, 2024
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 this pull request may close these issues.

2 participants