sumatrapdfreader / sumatrapdf

SumatraPDF reader
http://www.sumatrapdfreader.org
GNU General Public License v3.0
13.63k stars 1.73k forks source link

[FR] support loading different settings profiles #1327

Closed stevenlis closed 4 years ago

stevenlis commented 4 years ago

Please consider adding a feature to allow users to load different settings files so that they can change them quickly for different usage situations. For example, I adjusted the background and text colors but sometimes I do need them to be the default.

If there is a feature like this, I can quickly switch between them.

kjk commented 4 years ago

Sorry, no plans to do that. You can try to manually swap different setting files.

GitHubRulesOK commented 4 years ago

@StevenLi-DS

As you know from your latex and file commenting issues the setting file is dynamically changing throughout the session thus you are restricted to two prime methods of addressing this issue.

a) have two or more copies of settings file to load at start-up, that will not fix those two problems where your values are reset but would allow one file for dark one for light and as many other colours of the rainbow. At the start of sumatraPDF you tell it to change its -appdata directory the downside to that approach is you need to maintain multiple folders of settings, thumbnails and potentially crashdata. see https://forum.sumatrapdfreader.org/t/how-to-create-and-run-sessions-concurrently/2301/3

b) use a set of shortcuts or scripts to find and replace contents of the one settings file on the fly see https://github.com/sumatrapdfreader/sumatrapdf/issues/1027 downside is you are dependant on not corrupting the single settings file (and that can easily happen when meddling 😄 ) hence sumatrapdf resets parts of the file (which was your initial two problems 👎 )

Or if really adventurous a mix of both

Hints Some settings can be changed and take effect straight away, some changes need you to press R key to reload whilst viewing, and some need the session to be closed and restarted !.

stevenlis commented 4 years ago

Thanks for the comments. I was actually looking for a convenient way to switch settings. I saw the workaround of creating shortcuts while looking for a way to enable a dark mode. But I really wanna just double-click to open the reader.

GitHubRulesOK commented 4 years ago

@StevenLi-DS for what you desire option B) = edit on demand sounds like nearest current solution as file history should be maintained the alternative to "flip settings files" generally means NO carry across of file history etc

stevenlis commented 4 years ago

@GitHubRulesOK Thanks, hopefully you guys could reconsider the FR one day as it seems like many users wanna loading different sets.

stevenlis commented 4 years ago

possible you guys could consider reopening this issue and see if folks gotta upvote for this?

GitHubRulesOK commented 4 years ago

Hi Steven What may not be obvious to users is there is only 1 current author of SumatraPDF (kjk) others like me are a thorn in his side, pushing reminders and criticism :-) Over a long time, he has had to mold this efficient wrapper around issues in different PDF engines and for some time now that has been MuPDF. The settings file was initialy encoded and the -appdata function was more than adequate for easily switching profiles. As the advanced settings expanded and were opened up for easy user adjustment then file history. etc were added then the -appdata profiles were/are still good enough if file history , preferences favorites, tab settings etc. are excluded. It has evolved over a long time. A fix for one person can inevitably upset thousands of other users.

It would help user reliability if "settings" were changed to seperated parts as users could not make core color changes but could wipe parts of tab history etc. etc. that request has been raised as an issue but it affects lots of other inter-related functions

SumatraPeter commented 4 years ago

[Moved from #1289]

If you make changes outside of sumatra, we'll over-write them.

@kjk: Please note I'm not talking about having Sumatra running while editing the settings file. The point is that Sumatra seems to simply wipe out any commented settings. For example, suppose we have:

FixedPageUI [
# Black Text on White Background Profile
#   TextColor = #000000
#   BackgroundColor = #ffffff
# White Text on Black Background Profile
    TextColor = #ffffff
    BackgroundColor = #000000
]

If we save & close the settings file and then run Sumatra and close it, we simply end up with:

FixedPageUI [
    TextColor = #ffffff
    BackgroundColor = #000000
]

Thus it wipes out any commented settings (plus descriptions!) and leaves only uncommented ones behind. If it ignored all commented lines including settings, we could have multiple lines in there with different combinations of colors, which we could comment and uncomment as we see fit.

Currently the alternative is that we need to replicate the entire file if we want to have different profiles with different values for the same settings.

kjk commented 4 years ago

I understand but this is expected behavior and follows from how things work internally.

When the state changes (like you open a new file or advance the page), we serialize the state to settings file.

New state overwrites the old settings file.

We don't have a way to represent comments, so they are not present in serialized state so they are overwritten.

It would be a considerable amount of work to be more clever about it.

stevenlis commented 4 years ago

@GitHubRulesOK @kjk is that possible to add a button to allow users switch appdata in the UI? I wouldn't mind if the reader needs to be reloaded to apply the new settings.

GitHubRulesOK commented 4 years ago

@StevenLi-DS As you have noticed it is best/necessary to close and reload the settings This is exactly how you can have two different settings files and use the -appdata folder for each settings file. nothing is different from years ago. HOWEVER any change in history in one settings CANNOT be transfered to the other without a considerable amount of recoding to check each change.

So with that in mind it is easiest to say have dual settings 1) for my night reading list of books and another for 2) my daytime bills in glorious technicolour the diffence in history is then not a problem unless you need to check the nightlight power consumption.

It is 25 different appdata folders that allowed me to have 25 different latex inverse settings

SumatraPeter commented 4 years ago

We don't have a way to represent comments, so they are not present in serialized state so they are overwritten.

So what you're saying @kjk is that only the following 2 default comments are retained in the settings file, no matter what?

# For documentation, see https://www.sumatrapdfreader.org/settings3.2.html # Settings after this line have not been recognized by the current version

If so, that's a shame since it would have been nice to have the ability to insert our own commented lines.


BTW, how do you deal with multiple copies of the same setting? For example, if we have BackgroundColor = #ffffff and BackgroundColor = #000000, does the serialization simply ignore the 2nd copy onwards, or does it retain only the last copy?

kjk commented 4 years ago

Yes, the top comments are fixed and part of the template.

We ignore comments on loading everywhere but the only comments we save is this preamble at the top.

On Sun, Dec 15, 2019 at 3:27 PM Peter notifications@github.com wrote:

We don't have a way to represent comments, so they are not present in serialized state so they are overwritten.

So what you're saying @kjk https://github.com/kjk is that only the following 2 default comments are retained in the settings file, no matter what?

For documentation, see https://www.sumatrapdfreader.org/settings3.2.html

Settings after this line have not been recognized by the current version

If so, that's a shame since it would have been nice to have the ability to insert our own commented lines.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sumatrapdfreader/sumatrapdf/issues/1327?email_source=notifications&email_token=AAAB572HUWR2LJTGW57KYV3QY24PFA5CNFSM4J2Y66DKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG5FASI#issuecomment-565858377, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAB576NTXAKU3JSCENSJOTQY24PFANCNFSM4J2Y66DA .

stevenlis commented 4 years ago

@GitHubRulesOK Hi, buddy... are you using Wins? Based on my understandings from the links you attached I need to right-click the file and then "open with" to select the shortcut associated with a specific appdata, right?

Could you please attach a gif or screenshots?

GitHubRulesOK commented 4 years ago

@StevenLi-DS There are several places that the word "appdata" is applied in windows The specific use here is as a command line "switch" so when you start one session of SumatraPDF.exe it will load settings from one given location and with a different folder load a different profile.

If we were running in a dos prompt it would be like

    SumatraPDF.exe -appdata "c:\personal\profile1" "My Utility Bill.pdf"
    SumatraPDF.exe -appdata "c:\personal\profile2" "Nightime News Today.pdf"

etc. So first off you need to create two easy to find EMPTY folders like c:\personal\profile# (call them what you want but avoid using special characters or spaces)

now the fun part perhaps you have a SumatraPDF tile or one in your task bar or desktop however the easist way to setup and test is build a pair of new SumatraPDF shortcuts so on your desktop right-click and select new shortcut

image

use the browse button to find Sumatrapdf.exe add standard double quotes at each end if they were not automatically added.

NOTE " (standard double quote) can get corrupted by copy and paste from the web so always write them using your own keyboard

image

Add a space after the double quotes then -appdata then space "quoted first folder name" like this -appdata "C:\my own profile\1stFolder"

image

untitled

Start the shortcut to check it works by verifying there is a fresh settings.txt file in the 1st folder

Ok good now do the same thing for second profile but change the end of shortcut to -appdata "C:\my own profile\2ndFolder" check there is a second settings.txt in the second folder

The shortcuts allow for drag and drop on either shortcut try that out

stevenlis commented 4 years ago

Thanks for the details and it definitely helps! I just did It.

GitHubRulesOK commented 4 years ago

@StevenLi-DS Ok it answers your issue of support loading different profiles (it was already there for sequential sessions) There might be ways to attempt switching during current session but that is more likely to fail. If you need two seperate concurrent (same time) profiles you need 2 seperate sumatrapdf.exe

The main downside with seperate settings files is that the file opening history is stored within each settings.txt so one session cannot know what history another session has / had

stevenlis commented 4 years ago

Thanks man. The current workaround works fine for me. At the moment, I'm more interested in the highlight feature and wish it could be added into the stable release soon.

GitHubRulesOK commented 4 years ago

@StevenLi-DS I would not hold your breath highlight handling is a nightmare and might be fixed overnight by leprechauns but they are not good at C++, at best it might be re-enabled as it was in pre-release. I value the ability to use in formats such as plain text chm etc. but I personally pay for pdf editors :-) MuPDF-GL Annotator is very basic.

stevenlis commented 4 years ago

@GitHubRulesOK for me highlighting is perhaps the only feature that is missing for my workflow... I'm using the latest version of adobe pdf reader for that now.