Skip to content

Commit c5c131f

Browse files
Merge pull request #5895 from MicrosoftDocs/main
Auto Publish – main to live - 2025-10-15 23:35 UTC
2 parents c5fb510 + 5cc875f commit c5c131f

6 files changed

Lines changed: 99 additions & 7 deletions

File tree

hub/dev-environment/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,8 @@ items:
820820
href: ../powertoys/command-palette/microsoft-commandpalette-extensions-toolkit/utilities_ispackaged.md
821821
- name: Color Picker
822822
href: ../powertoys/color-picker.md
823+
- name: Light Switch
824+
href: ../powertoys/light-switch.md
823825
- name: PowerToys Run
824826
href: ../powertoys/run.md
825827
- name: Screen Ruler
1.79 MB
Loading

hub/images/pt-light-switch.png

88.6 KB
Loading

hub/powertoys/command-palette/using-markdown-content.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
---
2-
title: Display markdown content
3-
description: Learn how to display markdown in your Command Palette extension.
4-
ms.date: 3/23/2025
2+
title: Display markdown content in Command Palette extensions
3+
description: Learn how to display markdown content in your Command Palette extension. Create rich documentation, file previews, and interactive tutorials with formatted text and embedded commands.
4+
ms.date: 09/30/2025
55
ms.topic: how-to
66
no-loc: [PowerToys, Windows, Insider]
7-
# Customer intent: As a Windows developer, I want to learn how to develop an extension for the Command Palette.
7+
# Customer intent: As a Windows developer, I want to learn how to develop an extension for the Command Palette that displays markdown content, so that I can provide rich documentation or previews within the Command Palette.
88
---
99

1010
# Display markdown content
1111

1212
**Previous**: [Command Results](command-results.md)
1313

14+
The Command Palette supports rich content display beyond simple command lists. You can create extensions that show formatted text, documentation, and interactive content using markdown. This capability is particularly useful for:
15+
16+
- Displaying help documentation or user guides
17+
- Showing file previews or summaries
18+
- Providing formatted instructions or tutorials
19+
- Creating interactive content with embedded commands
20+
21+
This article shows you how to create pages that display markdown content in your Command Palette extension.
22+
1423
So far, we've only shown how to display a list of commands in a **ListPage**. However, you can also display rich content in your extension, such as markdown. This can be useful for showing documentation, or a preview of a document.
1524

1625
## Working with markdown content
@@ -63,7 +72,7 @@ public <ExtensionName>CommandsProvider()
6372

6473
In this example, a new `ContentPage` that displays a simple markdown string is created. The 'MarkdownContent' class takes a string of markdown content and renders it in the Command Palette.
6574

66-
![Screenshot of extension using ContentPage for markdown](../../images/command-palette/markdown.png)
75+
:::image type="content" source="../../images/command-palette/markdown.png" alt-text="Screenshot of Command Palette extension displaying markdown content with formatted text and document icon.":::
6776

6877
You can also add multiple blocks of content to a page. For example, you can add two blocks of markdown content.
6978

@@ -122,9 +131,39 @@ public class <ExtensionName>Page : ContentPage
122131
1. Select \<ExtensionName\>
123132
1. Press `Enter` key, the docs should open
124133

125-
![Screenshot of extension using CommandContextItem](../../images/command-palette/command-context-item.png)
134+
:::image type="content" source="../../images/command-palette/command-context-item.png" alt-text="Screenshot of Command Palette extension showing CommandContextItem with Open in File Explorer option.":::
135+
136+
## Add images to markdown content
137+
138+
With Command Palette in PowerToys 0.95 and later, you can add images to your markdown content from additional sources using one of the following schemes:
139+
140+
- File scheme: Enables loading images using the `file:` scheme.
141+
- This scheme intentionally restricts file URIs to absolute paths to ensure correct resolution when passed through the Command Palette extension/host boundary. In most cases, 3rd-party extensions provide the paths. However, the Command Palette host performs the actual loading and would otherwise resolve paths relative to itself.
142+
- Data scheme: Enables loading images from URIs with the `data:` scheme (both Base64 and URL-encoded forms).
143+
- **Note**: Before the changes introduced in PowerToys 0.95 and later, the markdown control could hang or become unresponsive when processing very large input, such as images larger than 5 MB or with dimensions exceeding 4000×4000 pixels, or markdown files exceeding 1 MB in size. Even with the changes, it is recommended to keep image file sizes below 5 MB and resize images to reasonable dimensions before embedding. For best results, compress images and split very large markdown content into smaller sections where possible.
144+
- `ms-appx` scheme: This scheme is now supported for loading images.
145+
- **Note**: Since the Command Palette host performs the loading, `ms-appx:` resolution applies to the host and not the extensions, which limits its usefulness.
146+
- `ms-appdata` scheme: This scheme is now supported for loading images.
147+
- Similar to `ms-appx:`, `ms-appdata:` resolution applies to the host, not the extensions. This limits its usefulness for 3rd-party extensions.
148+
149+
Additionally, Command Palette in PowerToys 0.95 and later introduces the concept of image source hints, implemented as query string parameters piggy-backed on the original URI.
150+
151+
These hints allow extension developers to influence the behavior of images within the markdown content.
152+
153+
- `--x-cmdpal-fit`
154+
- `none`: No automatic scaling, provides image as is (default)
155+
- `fit`: Scale to fit the available space
156+
- `--x-cmdpal-upscale`
157+
- `true`: Allow upscaling
158+
- `false`: Downscale only (default)
159+
- `--x-cmdpal-width`: Desired width in pixels
160+
- `--x-cmdpal-height`: Desired height in pixels
161+
- `--x-cmdpal-maxwidth`: Max width in pixels
162+
- `--x-cmdpal-maxheight`: Max height in pixels
163+
164+
See the [SampleMarkdownImages](https://github.com/microsoft/PowerToys/blob/main/src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleMarkdownImagesPage.cs) page in the [SamplePagesExtension](https://github.com/microsoft/PowerToys/tree/main/src/modules/cmdpal/ext/SamplePagesExtension) generic sample project in the PowerToys GitHub repository for examples of using images in your extension's markdown content.
126165

127-
### Next up: [Get user input with forms](using-form-pages.md)
166+
## Next up: [Get user input with forms](using-form-pages.md)
128167

129168
## Related content
130169

hub/powertoys/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ The currently available utilities include:
184184
:::column-end:::
185185
:::row-end:::
186186

187+
### Light Switch
188+
189+
:::row:::
190+
:::column:::
191+
[![A screenshot of the Light Switch PowerToys utility for Windows.](../images/pt-light-switch.png)](light-switch.md)
192+
:::column-end:::
193+
:::column span="2":::
194+
[Light Switch](light-switch.md) allows you to automatically switch between light and dark themes in Windows based on the time of day.
195+
:::column-end:::
196+
:::row-end:::
197+
187198
### Mouse utilities
188199

189200
:::row:::

hub/powertoys/light-switch.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Manage your Windows theme with Light Switch
3+
description: Learn how to automatically switch between light and dark themes in Windows using PowerToys Light Switch. Reduce eye strain and save battery life.
4+
ms.date: 09/30/2025
5+
ms.topic: concept-article
6+
ms.localizationpriority: medium
7+
no-loc: [PowerToys, Windows, themes, Light Switch]
8+
# Customer intent: As a Windows power user, I want to use PowerToys Light Switch to automatically change my Windows theme based on the time of day, so that I can have a more comfortable viewing experience.
9+
---
10+
11+
# Light Switch utility
12+
13+
Light Switch is a PowerToys utility that automatically switches your Windows theme between light and dark modes based on time of day. You can configure Light Switch to change themes automatically using sunrise and sunset times in your location, or set custom schedules that work best for your daily routine.
14+
15+
Benefits of using Light Switch include:
16+
17+
- **Reduced eye strain** - Dark themes are easier on your eyes in low-light environments
18+
- **Better battery life** - Dark themes can help extend battery life on devices with OLED displays
19+
- **Automatic adaptation** - No need to manually change themes throughout the day
20+
21+
## How to activate and use Light Switch
22+
23+
Light Switch is enabled by default, but you can activate or deactivate it by opening PowerToys Settings and changing the **Enable Light Switch** toggle. You can then configure the settings to specify the times for switching between light and dark themes based on your local sunrise and sunset times or manually set times.
24+
25+
:::image type="content" source="../images/pt-light-switch-settings.gif" alt-text="An animated GIF of the Light Switch settings.":::
26+
27+
The following settings are available for Light Switch:
28+
29+
| Setting | Description |
30+
| :-- | :-- |
31+
| Enable Light Switch | Turn the Light Switch utility on or off. |
32+
| Theme toggle shortcut | Set a keyboard shortcut to manually toggle between light and dark themes. |
33+
| Mode | Choose between using dark mode from **Sunset to Sunrise** (automatic based on your location) or **Manual** (set specific times). Note that you must have location services enabled and synced for automatic mode to work. |
34+
| Location | Sync your location to enable automatic switching based on local sunrise and sunset times. |
35+
| Offset in minutes | Adjust the time for switching themes by a specified number of minutes before or after sunrise and sunset. |
36+
| Turn on dark mode | Set the time to switch to dark mode when using manual mode. |
37+
| Turn on light mode | Set the time to switch to light mode when using manual mode. |
38+
| Apply dark mode to | Choose whether Light Switch applies dark mode to **System** (Taskbar, Start, and other system UI) and/or **Apps** (supported apps). |
39+
40+
[!INCLUDE [install-powertoys.md](../includes/install-powertoys.md)]

0 commit comments

Comments
 (0)