Page 1 of 1
Churn in xnview.ini file
Posted: Wed Mar 19, 2025 9:53 pm
by trystero
Using XnView MP 1.8.6 on macOS Sequoia 15.3.2.
I keep my INI file –
~/.config/xnviewmp/xnview.ini – in version control so I don't lose my settings. Every time I close XnView MP, though, the values in the file are rewritten in a different order even though I haven't changed any settings. This results in continual churn in the file. Ideally XnView MP would write out its settings consistently so that my version-control tool only reports changes when I've actually changed my settings.
Example: changes shown by "git diff" after I've opened XnView MP and closed it again (no operations, no changes of any kind):
Code: Select all
% git diff
diff --git a/.config/xnviewmp/xnview.ini b/.config/xnviewmp/xnview.ini
index 2f0b5c4..e6deccb 100644
--- a/.config/xnviewmp/xnview.ini
+++ b/.config/xnviewmp/xnview.ini
@@ -283,14 +283,14 @@ preview=false
[Format]
="======"
-archive=tar rar tgz gz arj zip
-audio=au wma flac snd rmi ogg aif mid wav asx mp+ mp2 mp3 mpc mpp
-avi=vfw wmv vob divx asf avi
-mpeg=m1s m1v mts m2ts m2v m4a mpeg mp4 mpa mpe mpg mpm
-ps=ai pdf eps ps epsf
-qt=3gp2 3g2 qt 3gp mov
-text=xmp cc ini c h pas js c++ php cpp gcode txt css
-video=webm flv rm mkv
+archive=gz arj zip tar rar tgz
+audio=au mid flac wav asx mp+ mp2 mp3 mpc mpp wma snd rmi ogg aif
+avi=asf divx avi vfw wmv vob
+mpeg=m2ts mp4 mpa mpe mpg mpeg mpm m1s m1v mts m2v m4a
+ps=ai ps epsf pdf eps
+qt=3gp 3gp2 mov qt 3g2
+text=cpp cc c txt h css gcode js xmp ini pas c++ php
+video=mkv rm flv webm
If these format assignments were written out in alphabetical order, git would not show them as changed after every run.
Re: Churn in xnview.ini file
Posted: Fri May 23, 2025 3:05 pm
by Neuro-NX
JSON is a better serialized format for version control or backup purposes.
For those wanting to backup their xnview.ini file.
I created a python script that will convert an INI file to JSON. Here =>
https://gist.github.com/Neuro-NX/d0d4a0 ... 2c6ac50e25
You can then backup the JSON file in Linux or macOS, like this
Code: Select all
python ini-json-convert.py -i xnview.ini -f json > xnview.json
To convert the JSON file back to INI.
Code: Select all
python ini-json-convert.py -i xnview.json -f ini > xnview.ini
Re: Churn in xnview.ini file
Posted: Fri May 23, 2025 3:09 pm
by trystero
Thanks for the suggestion and Python script! I'll try that out…
Re: Churn in xnview.ini file
Posted: Fri May 23, 2025 3:27 pm
by Neuro-NX
Sorry. I just noticed an issue. The INI file is using "camelCase" for KEYs.
Please use the updated revision, which preserves the case
https://gist.github.com/Neuro-NX/d0d4a0 ... 2c6ac50e25
Re: Churn in xnview.ini file
Posted: Fri May 23, 2025 5:37 pm
by Neuro-NX
trystero wrote: Fri May 23, 2025 3:09 pm
Thanks for the suggestion and Python script! I'll try that out…
Okay. I improved the script to format the INI file properly and provide the features you wanted.
As you want to perform version control, the INI file needs to be sorted alphabetically. It can now take an argument flag '-s' to sort alphabetically. By default, it will separate KEY:VALUE with a space "KEY = VALUE". To remove this to be "KEY=VALUE" you can pass argument flag '--no-space'.
Code: Select all
python ini-json-convert.py -i xnview.json -f ini -s --no-space > xnview.ini
Here is the updated revision.
https://gist.github.com/Neuro-NX/d0d4a0 ... cee9e30f3
Disable history for version control
Posted: Fri May 23, 2025 7:55 pm
by Neuro-NX
If you intend on doing version control or backup of
xnview.ini. You should also consider, removing history of files from being logged. Not just for privacy reasons, but that it will produce a false positive when doing 'diff', as these values change all the time as you use the program.
Code: Select all
[%General]
maxRecent=0
purgeRecent=true
[File]
History=@Invalid()
LastUsed=false
[Start]
History=@Invalid()
RecentFiles=@Invalid()
LastFilename=""
[toolbarSearch]
recentSearches=@Invalid()
[Convert]
History=@Invalid()
[Search]
filename=@Invalid()
folder=@Invalid()
Note, that it is not possible to disable logging for some KEYs. As the value will be rewritten. Currently, this is the case with Search > filename, folder and some others. In which case, I am using
@Invalid() as a placeholder. You would need to write a python or shell script, that searches xnview.ini for the line to be changed, and replace the VALUE you want removed, with your chosen placeholder, before you commit your revision, or backup the file.
Re: Churn in xnview.ini file
Posted: Fri May 23, 2025 8:24 pm
by trystero
I've tried the latest updated version of your Python script, and it's giving me errors when trying to parse the four lines in my xview.ini file that look like this:
When I run the script, the exception stack comes down to this error:
Code: Select all
configparser.ParsingError: Source contains parsing errors: 'xnview.ini'
[line 183]: '="======"\n'
[line 285]: '="======"\n'
[line 628]: '="======"\n'
[line 669]: '="======"\n'
Re: Churn in xnview.ini file
Posted: Fri May 23, 2025 8:27 pm
by Neuro-NX
Can you provide the fulll line from xnview.ini.
Re: Churn in xnview.ini file
Posted: Fri May 23, 2025 8:29 pm
by trystero
Here's a section of my xnview.ini file, starting at line 182:
Code: Select all
[Convert]
="======"
AllPages=false
BackColor=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0)
Case=0
ClearFilename=false
As you can see, line 183, where the parser is throwing an error, is just an equals sign followed by six more equals signs inside double quotes. I have no idea what purpose is served by this line, or by the other three later on in the INI file that look just like it, which appear right after the [Format], [Start], and [Viewer] section headers.
Re: Churn in xnview.ini file
Posted: Fri May 23, 2025 8:51 pm
by Neuro-NX
I can't replicate this, or find it within my xnview.ini. I am using version 1.8.8 (Linux).
I would simply remove that line for now. It's not important. It is not valid, because it is missing the KEY. For example, it should be
.
Within Batch convert, there are numerous options that could be the culprit, but I would have to do some tests. This seems like an internal bug, that was caused by one of the options not being assigned a KEY within xnview.ini, which may be why the KEY is missing.
Re: Churn in xnview.ini file
Posted: Sat May 24, 2025 1:30 am
by trystero
I'm using XnView MP 1.8.8 64-bit (MacOS) - Libformat 7.221. I can strip out those weird lines, but I didn't put them in, so I'm guessing XnView MP will put them back in at some point.