Add /config=<name> cmd line argument for using a specified user configuration file #764
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
I'm using my scanner (CanoScan 4400F) to archive documents as PDFs. Business documents need to be stored in a Papra DMS ingestion folder while personal or household documents have to be archived in separate folder structures. I can therefore not currently use a common default file path in the PDF settings but instead have to select the path manually for each document which is tiresome.
Proposed Solution
The proposed changes attempt to resolve this issue by adding a new command line argument:
If such a name is specified it is
a) used as a suffix for the XML file used to load and store user configuration values, and
b) displayed in the main window title.
If no such argument is used the behaviour is unchanged. If multiple
/config=...arguments are used only the first one has an effect.Example
For example, specifying
/config=Businessresults in the fileconfig_Business.xmlto be used for the user configuration values.Additionally the title of the main window will display the configuration name:
Any changes to settings values will be saved in
config_Business.xml. Other user configuration files are not affected.Special cases
While best avoided, spaces in configuration names can be used by putting the complete argument in quotes, e. g.
"/config=My Business". The configuration name is being checked for invalid file name characters. If any are present, or if its trimmed string is empty, the argument is ignored.Usage
This option is mainly intended to be used for AutoPlay event handlers that are applied when buttons on the scanner are pressed. Regular users of the GUI will probably not use it much. Perhaps it can be useful for batch processing as well but I have not yet used that.
On Windows the event handlers for the scanner buttons can now be modified in the registry to use different configurations of with each can define a different default file path. Once the GUI is up and running subsequent invocations (i. e. scanner button clicks) do not change the configuration used at startup even if a command line argument should specify a different one. The window needs to be closed in order to be able to use a different configuration.
Example:
To use the configuration "Business" when clicking the leftmost button (on a CanoScan 4400F) add the argument
/config=Businessto the value ofCmdlineunder the keyComputer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{6bdd1fc6-810f-11d0-bec7-08002be2092f}\0004\Events\PushButtonPushed4\{1C3A7177-F3A7-439E-BE47-E304A185F932}:Platforms
Windows: Functional (tested on Windows 10)
Linux: Functional (tested on Linux Mint 22)
Mac OS: Untested
Addendum
I have not added or modified tests or documentation. I hope this patch is useful for the project; if there is anything else I can do please let me know.