anufrievroman / waypaper

GUI wallpaper manager for Wayland and Xorg Linux systems
https://anufrievroman.gitbook.io/waypaper
GNU General Public License v3.0
396 stars 27 forks source link

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

Closed jjramsey closed 4 months ago

jjramsey commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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