Add DSC v3 profile resource to deploy key and shortcut remappings - #49427
Add DSC v3 profile resource to deploy key and shortcut remappings#49427Gijs Reijn (Gijsreyn) wants to merge 14 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
|
||
| [JsonPropertyName("runProgramStartInDir")] | ||
| [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
| public string RunProgramStartInDir { get; set; } |
There was a problem hiding this comment.
Since the DSC implementation is currently depending on shared Keyboard Manager/UI code, I think it’s worth reconsidering this model change. The safer design may be for DSC to own its own storage/model types and translate to the shared library shape only where needed, rather than expanding the shared model for DSC-specific needs. I’m not a maintainer on this area, but my guess is the team may prefer keeping DSC-specific augmentation isolated from the shared library contract
|
Muyuan Li (@MuyuanMS) - thanks for leaving a couple of comments. Are those all something you want me to fix? |
Muyuan Li (MuyuanMS)
left a comment
There was a problem hiding this comment.
One follow-up still needs an author decision in src/dsc/v3/PowerToys.DSC/Properties/Resources.resx: either localize the full validation diagnostics emitted for profile import/export problems, or narrow the user-facing checklist/resource text so it only promises the stable localized prefixes that are actually guaranteed today.
Apologies, I was trying to leverage gh api to make inline code suggestions but somehow messed up. Thanks for the quick response to let me know it failed. I've corrected it and now the comments should be valid |
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
…ps://github.com/Gijsreyn/PowerToys into microsoftgh-38233/main/add-dsc-profile-resource
|
Muyuan Li (@MuyuanMS) - I took your suggestions, thanks a lot. I also updated the PowerShell script in the Localizing them would add ~25 resource strings plus format-threading through the static converter/parser, while making errors harder to correlate with the document they describe. This also follows the existing pattern in |
Summary of the Pull Request
Adds a new DSC v3 resource,
profile(Microsoft.PowerToys/KeyboardManagerProfile), toPowerToys.DSC.exethat makes Keyboard Manager key and shortcut remappings deployable viadsc.exeandwinget configure. Until now, DSC only controlled whether Keyboard Manager is enabled — the actual remappings could only be created through the Keyboard Manager editor UI.Remappings are authored with friendly, layout-invariant key names instead of raw virtual-key codes:
The resource supports
get/set/test/export/schema/manifest, applies replace-whole-profile semantics (declarative desired state), writes the exact profile encoding the C++ editor produces, and signals a running Keyboard Manager engine to reload the remappings immediately, meaning no PowerToys restart is required.PR Checklist
export+set)PowerToys.DSCResources.resx; generated DSC manifest descriptions are deliberately not localized, matching the existingsettingsresource)doc/dsc/profile-resource.md,doc/dsc/overview.md,doc/dsc/modules/KeyboardManager.md,doc/devdocs/core/settings/dsc-configure.md)PowerToys.DSC.exe. The additional generated manifest (microsoft.powertoys.KeyboardManager.profile.dsc.resource.json) is picked up automatically by the installer's unfilteredDSCModules\component glob (generateAllFileComponents.ps1)PowerToys.DSC.UnitTestsprojectDetailed Description of the Pull Request / Additional comments
As remarked by AmirMS (@AmelBawa-msft) on the issue, rempapings don't live in
settings.json. They're stored in a separate profile file:%LOCALAPPDATA%\Microsoft\PowerToys\Keyboard Manager\<activeConfiguration>.json. The only KBM properties that reference it insettings.jsonare marked[CmdConfigureIgnore]((activeConfiguration,keyboardConfigurations).The legacy PowerShell-based
PowerToysConfigure(v2/winget 0.2 schema) path was deliberately not chosen. It drives settings through a scalarPowerToys.Settings.exe set <Module>.<Property> <value>protocol; nested lists only work through the special-casedsetAdditionalside-channel, which merges by aNamekey into the module'ssettings.jsonand cannot target the separate profile file. ItsSet()also would have killed, requiring a restart for PowerToys.The style is also in friendly strings and not in
HotkeySettings-stylish, as the shape couldn't express what remappings it needed.