[Kbm] Save the remaps to file[part-1]#2184
Conversation
|
I noticed that the JSON file is loaded only when runner is launched. Just wanted to confirm is that how all the PowerToys behave? Like if I modify the JSON file after it is launched it will not recognize it? I suppose we can assume the user will not manually modify the JSON but I wanted to clarify that. And will that make the Settings UI side harder since I guess that will be reloaded whenever the file is changed? |
| public class KeyboadManagerConfigModel | ||
| { | ||
| [JsonPropertyName("remapKeys")] | ||
| public List<KeysDataModel> RemapKeys { get; set; } |
There was a problem hiding this comment.
Since we will be incorporating the registry approach in the future, we can add inProcess and registry subkeys to distinguish the two, or we can just add a separate key which checks if it is inProcess or registry. @saahmedm will we be allowing users to have active key to key remappings in both the registry and in process methods at the same time or will they be independent? Even if they are independent will we allow them to save some remappings of both methods in the config file that and then they toggle between the two with some switch or something? How we plan to handle that will affect how we structure the JSON to avoid a breaking change in the future.
Here's an example scenario:
Maybe the user prefers registry remaps in general and they remap a to b, b to c, etc with registry method. Then the user wants to remap RAlt but the SharpKeys approach doesn't support that afaik. So would we support a scenario where:
- User can also add an inprocess remap for a few keys (as long as they are independent of the registry method)
OR - User can save some set of remappings like
RAltto something with in process and they can switch between this and the registry approach (the remappings for both approaches would be stored). It would still need a reboot to switch between the two obviously.
There was a problem hiding this comment.
@arjunbalgovind with your second scenario, where they switch between these. they would both be on a single config file? or that they switch to a config file with in-process remapping
There was a problem hiding this comment.
For both scenarios I meant single config file. A third scenario would be where you would need to switch to another config for that. Or in essence your config file only stores one method of key to key remapping.
There was a problem hiding this comment.
I have included the inProcess subkey in the data model for now. @saahmedm for the case if we want both the approaches independent what will happen when user choose to select the regsitry approach will we move all the single key remappings to registry(if possible) or have a separate list of remapping for both of the cases?
There was a problem hiding this comment.
missed this guys. imo at one point users should be able to remap keys in-process and registry level at the same time. so the first scenario @arjunbalgovind mentioned.
There was a problem hiding this comment.
I think we can make that change on a separate PR, since this already merged. @saahmedm can you make an issue to track adjusting the JSON to support future in-process and registry remaps? We can mark that as a P0 so that the change is made before Build.
|
Where will the Enabled attribute for KBM be stored? Is it to be in the common settings.json? Cause I noticed that the Enable toggle doesnt work right now |
Yes in the current implementation it will load only on the startup. In other modules, SettingsV2 process currently sends an Ipc message to |
That's a good catch I missed the enable/disable logic for |
arjunbalgovind
left a comment
There was a problem hiding this comment.
LGTM! I think you'll have to resolve some merge conflicts from the latest changes, but apart from that great work! :)
Summary of the Pull Request
Adding the logic to save the Keyboard Manager configuration to file, persist the configuration on restart and event trigger in Settings to fetch the updates in configuration.
Todo(In a separate PR ): Update the UI on settings list view to reflect the real data.
PR Checklist
Detailed Description of the Pull Request / Additional comments
settings.jsonin a separate fileconfig-name.json. This will be make the support of multiple configuration easier and configurations file can be shared or use templates.VK_WIN.settings-updated.jsonto communicate to Settings process that the config json have been successfully updated so settings process can read the file. The reason for using becauseFileSystemWatcherraises trigger events multiple time during a file update and the settings process have no knowledge if the runner process is still writing to the file. Alternatively, a polling approach can be used here as well to retry after sometime to see if file is free.FileSystemWatcherfires multiple events on writing to a file. Added a logic to treat all the events fired with a Time threshold as one.Validation Steps Performed
Validate the changes locally.