Skip to main content

Overview

The PowerToys settings system provides a comprehensive framework for configuring modules through a WinUI 3-based Settings application. The system uses JSON-based configuration files, inter-process communication via Named Pipes, and a layered architecture to ensure settings are properly synchronized between the Settings UI, Runner, and individual modules.

Architecture

Reference: doc/devdocs/core/settings/readme.md

JSON Configuration Files

Settings are stored as JSON files in %LOCALAPPDATA%\Microsoft\PowerToys\.

General Settings

File: settings.json

Module Settings

File: <ModuleName>/settings.json
JSON Schema:
  • version: Schema version (for migration support)
  • name: Module identifier
  • properties: Object containing all module settings
    • Each setting has a value field
    • Settings can be boolean, number, string, or object
Reference: doc/devdocs/core/settings/settings-implementation.md:1-29

IPC Communication

Pipe Initialization

The Settings UI and Runner establish a bi-directional Named Pipe connection on startup. Settings UI Side (C#):
Runner Side (C++):
Reference: doc/devdocs/core/settings/runner-ipc.md:5-8, doc/devdocs/core/runner.md:76-91

Message Types

The Settings UI defines three types of IPC delegates for communication:
  1. SendDefaultMessage - Used by ViewModels to send settings changes
  2. RestartAsAdmin - Request elevation
  3. CheckForUpdates - Trigger update check
Reference: doc/devdocs/core/settings/runner-ipc.md:10-14

Sending Settings to Runner

General Settings Message:
Module Settings Message:
Implementation:
Reference: doc/devdocs/core/settings/runner-ipc.md:16-20

Receiving Messages from Runner

Setup Handler List:
Message Handling Example:
Reference: doc/devdocs/core/settings/runner-ipc.md:21-47

Settings Implementation in Modules

C++ Module Settings

Reading Settings:
Writing Settings:
Reference: doc/devdocs/core/settings/settings-implementation.md:5-29

C# Module Settings

Settings Data Model:
Reading Settings:
Writing Settings:
Reference: doc/devdocs/core/settings/settings-implementation.md:31-54

Settings UI Implementation

1. Settings Data Model

Define your module’s settings class in Settings.UI.Library:
Reference: doc/devdocs/core/settings/settings-implementation.md:131-136

2. ViewModel

Create a ViewModel that inherits from Observable and manages the settings:
Reference: doc/devdocs/core/settings/settings-implementation.md:151-156, doc/devdocs/core/settings/viewmodels.md

3. Settings Page (XAML)

Create a settings page with UI controls bound to the ViewModel:
Code-behind:
Reference: doc/devdocs/core/settings/settings-implementation.md:147-150, doc/devdocs/core/settings/ui-architecture.md

4. Add to Navigation

Register your settings page in ShellPage.xaml:
Reference: doc/devdocs/core/settings/settings-implementation.md:140-144

Hotkey Conflict Detection

The Settings UI implements hotkey conflict detection to warn users when multiple modules use the same hotkey.

Implementation Steps

1. Module Interface - Return Hotkeys:
Important: The order of hotkeys must be consistent across all layers. 2. Settings Model - Implement IHotkeyConfig:
3. ViewModel - Return All Hotkeys:
4. Page - Call OnPageLoaded:
Reference: doc/devdocs/core/settings/settings-implementation.md:74-108

Alternative Communication Patterns

File-Based Settings (PowerToys Run)

Some modules watch settings files directly instead of using IPC:
Reference: doc/devdocs/core/settings/communication-with-modules.md:7-10

Shared File with Mutex (Keyboard Manager)

Keyboard Manager uses a named mutex for safe concurrent access:
Reference: doc/devdocs/core/settings/communication-with-modules.md:12-16

Debugging Settings

Common Issues

Debug Steps

  1. Check settings files in %LOCALAPPDATA%\Microsoft\PowerToys\
    • Verify JSON is well-formed
    • Check that values are being written
  2. Monitor IPC communication
    • Set breakpoints in Settings UI’s DefaultSndMSGCallBack
    • Set breakpoints in Runner’s message dispatcher
    • Log JSON messages being sent/received
  3. Check module’s set_config
    • Verify module receives configuration
    • Check JSON parsing logic
    • Ensure settings are applied to module state
  4. Review logs
    • Settings UI logs: %LOCALAPPDATA%\Microsoft\PowerToys\logs\Settings\
    • Runner logs: %LOCALAPPDATA%\Microsoft\PowerToys\logs\
    • Module logs: Look for module-specific log files
Reference: doc/devdocs/core/settings/settings-implementation.md:109-126

Next Steps

Module Interface

Implement the module interface with settings support

Runner Implementation

Understand how the Runner processes settings

Architecture Overview

High-level system architecture

UI Architecture

Settings UI architecture and patterns