Skip to content

[DSC] Implement Microsoft.PowerToys.Configure DSCResource & winget support #30918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Apr 1, 2024

Conversation

yuyoyuppe
Copy link
Contributor

@yuyoyuppe yuyoyuppe commented Jan 12, 2024

Summary of the Pull Request

Allows to configure most of PowerToys settings using winget configure like this:

# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
properties:
  resources:
    - resource: PowerToysConfigure
      directives:
        description: Configure PowerToys
      settings:
        ShortcutGuide:
          Enabled: false
        FancyZones:
          Enabled: true
          FancyzonesEditorHotkey: "Shift+Ctrl+Alt+F"
  configurationVersion: 0.2.0

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Sorry, something went wrong.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@htcfreek
Copy link
Collaborator

htcfreek commented Feb 7, 2024

I don't know how this will work inside PowerToys code. But we have to make sure that the Group Policies always in any case have the highest priority!

@yuyoyuppe
Copy link
Contributor Author

@htcfreek good point, thanks. In general, we must ensure that when a setting value in .json is edited - it's correctly applied and respected by both Settings and a module.

I'm afraid we'll encounter a number of bugs and we'll have to solve it in a setting-by-setting manner.

@yuyoyuppe yuyoyuppe force-pushed the dsc_configure_module branch from 3c69103 to c99dd8e Compare March 20, 2024 00:59

This comment has been minimized.

@yuyoyuppe yuyoyuppe force-pushed the dsc_configure_module branch from c99dd8e to d7663d6 Compare March 20, 2024 01:02
@yuyoyuppe yuyoyuppe marked this pull request as ready for review March 20, 2024 01:06
@yuyoyuppe
Copy link
Contributor Author

Implemented the remaining TODO items and merged the latest main.

@yuyoyuppe yuyoyuppe changed the title [WIP][DSC] Implement Microsoft.PowerToys.Configure DSCResource & winget support [DSC] Implement Microsoft.PowerToys.Configure DSCResource & winget support Mar 20, 2024
Copy link
Collaborator

@jaimecbernardo jaimecbernardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like lots of work went into refactoring some weird behaviors we had. Great work! I've done a first review and have some nits / questions.

Copyright = '(c) Microsoft Corporation. All rights reserved.'

# Description of the functionality provided by this module
# Description = ''
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to fill out any of these to comply? Can you please check for some advisory on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sent an email with the question regarding this

directives:
description: Configure PowerToys
settings:
Debug: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one needed? Why is Debug on this sample? It seems to be on every sample. I guess the samples don't need debug, since that's only for debugging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug is used so it's possible to test DSC without building an installer and performing an installation each time you change something. Changed to false.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuyoyuppe , why change it to false? It can be deleted from the file too, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be deleted, yes. It's convenient to have it here though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are the samples we are providing for people to look, please remove the Delete.

Debug: true
PowerLauncher:
Enabled: true
AdditionalProperties:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are plugins inside Additional Properties? That looks a bit weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plugins have multiple things that do not comply with the rest of the settings:

  • They're stored separately from Properties field unlike all other settings, see PowerLauncherSettings
  • They are stored in a IEnumerable which makes identifying them difficult, thus the inferring of "key" property (Name only at the moment) in SetAdditionalSettingsCommandLineCommand.Execute. Also, it's not clear whether we should append/combine/overwrite the elements in IEnumerable.

So yeah, currently they exist as a kind of special case due to their structure and extensibility.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuyoyuppe
For policies we use the plugin id as identification because this is the only thing that is 100% unique. From what I have in mind PowerLauncher deduplicates based on the id and newest version/date.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it named "AdditionalProperties", though? Is that the name in the json file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just the name I've picked. We could change it to something else.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So ti means we can just have "Plugins" instead of "Additional Properties>Plugins"? That would be preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way it works is more general than that though 🤔. Currently, it's a bit limited in terms of the supported types, but the logic could be extended to support all the properties, i.e. not only Plugins for PowerRun, but for the rest of the properties as well.

@@ -69,6 +70,7 @@ public ImageResizerProperties(Func<string, string> resourceLoader)
public StringProperty ImageresizerFileName { get; set; }

[JsonPropertyName("imageresizer_sizes")]
[CmdConfigureIgnoreAttribute]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So right now we're unable to do the ImageResizer sizes we want from DSC. Can we please document in the .md the current settings we're unable to configure at this moment? This looks like one that would be useful. Not saying we do it for V1, but we should keep track of what we're missing.

public GenericProperty<string> ActiveConfiguration { get; set; }

// List of all Keyboard Configurations.
[JsonPropertyName("keyboardConfigurations")]
[CmdConfigureIgnoreAttribute]
public GenericProperty<List<string>> KeyboardConfigurations { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we able to do KBM mappings through the DSC currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, doing multilevel generics needs additional handling.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please have a sample for this added, then? ;) Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, meant to say we can't do it yet. 😐

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a list of the Settings we don't currently support setting to the documentation.

Enabled: true
VideoConference:
Enabled: true
MeasureTool:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Settings we're showing different names for these, so we might need to add comments to the samples so people can understand what we're talking about for the ones that don't look like the names in the product. Thinking Measure Tool is actually Screen Ruler and Power Ocr is actually Text Extractor, for example. Or can we have aliases for these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was to add the documentation for all the settings. Having an alias is a good idea as well, I'll take a look

Comment on lines 11 to 13
Plugins:
- Name: "Calculator"
Disabled: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we only support disabled state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we support both states, that's just naming of the plugin properties here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear asked. Is this the only setting you can set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should support other options as well. Not the nested objects though. I'll compose a list of settable options for all modules and create a PR in https://github.com/MicrosoftDocs/windows-dev-docs/blob/docs/hub/powertoys/index.md

yuyoyuppe and others added 7 commits March 21, 2024 16:09
IgnoreHotkeysInFullscreen: false
ClearInputOnLaunch: false
TabSelectsContextButtons: false
Theme: HighContrastBlack
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder about this value. Is it matching to a selectable value in the settings ui?

SortByUsageFrequency: false
StartSelectionFromTheLeft: false

PowerLauncher:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the plugin sample for PT Run?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this the all Setting sample contains mostly noise. I think it's better to remove it at this point 🤷

Copy link
Collaborator

@jaimecbernardo jaimecbernardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still some changes that are required, I think. Or oversights in the changes.

<Directory Id="PowerShellModulesFolder" Name="Modules">
<Directory Id="PowerToysDscFolder" Name="Microsoft.PowerToys.Configure">
<Directory Id="PowerToysDscVerFolder" Name="$(var.Version)">
<Component Id="PowerToysDSC" Win64="yes" Guid="4A033E3B-6590-43FD-8FBD-27F9DF557F7F">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the component not fail the installation if the component is not able to be installed?

Enabled: true
Plugins:
- Name: "Calculator"
Disabled: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are other fields configurable here too for the plugins?

@@ -49,6 +58,7 @@ public class PowerLauncherProperties
public Theme Theme { get; set; }

[JsonPropertyName("show_plugins_overview")]
[CmdConfigureIgnore]
public int ShowPluginsOverview { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this one ignored too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's there on Settings, but it's an int instead of an Enum. We need to look into how to support it later on.

Copy link
Collaborator

@jaimecbernardo jaimecbernardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the latest changes. Good enough for a V1, at least. Thank you. Now waiting for CI to run before merging.

@jaimecbernardo jaimecbernardo merged commit f23fa3f into microsoft:main Apr 1, 2024
10 checks passed
@htcfreek
Copy link
Collaborator

htcfreek commented Apr 2, 2024

@yuyoyuppe , @jaimecbernardo
Ist the following run plugin setting configurable using dsc? If yes, please block this as it is an internal state configuration field.

https://github.com/microsoft/PowerToys/blob/main/src%2Fsettings-ui%2FSettings.UI.Library%2FPowerLauncherPluginSettings.cs#L23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants