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
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
version: Schema version (for migration support)name: Module identifierproperties: Object containing all module settings- Each setting has a
valuefield - Settings can be boolean, number, string, or object
- Each setting has a
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#):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:- SendDefaultMessage - Used by ViewModels to send settings changes
- RestartAsAdmin - Request elevation
- CheckForUpdates - Trigger update check
doc/devdocs/core/settings/runner-ipc.md:10-14
Sending Settings to Runner
General Settings Message:doc/devdocs/core/settings/runner-ipc.md:16-20
Receiving Messages from Runner
Setup Handler List:doc/devdocs/core/settings/runner-ipc.md:21-47
Settings Implementation in Modules
C++ Module Settings
Reading Settings:doc/devdocs/core/settings/settings-implementation.md:5-29
C# Module Settings
Settings Data Model:doc/devdocs/core/settings/settings-implementation.md:31-54
Settings UI Implementation
1. Settings Data Model
Define your module’s settings class inSettings.UI.Library:
doc/devdocs/core/settings/settings-implementation.md:131-136
2. ViewModel
Create a ViewModel that inherits fromObservable and manages the settings:
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:doc/devdocs/core/settings/settings-implementation.md:147-150, doc/devdocs/core/settings/ui-architecture.md
4. Add to Navigation
Register your settings page inShellPage.xaml:
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: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: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:doc/devdocs/core/settings/communication-with-modules.md:12-16
Debugging Settings
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| Settings not saving | File permissions | Check write access to %LOCALAPPDATA%\Microsoft\PowerToys\ |
| Settings not applied | IPC not working | Check Named Pipe connection, look for errors in logs |
| Incorrect values | JSON parsing error | Validate JSON format, check for type mismatches |
| Conflicts with other processes | File locks | Use mutex for shared files, check for file handles |
Debug Steps
-
Check settings files in
%LOCALAPPDATA%\Microsoft\PowerToys\- Verify JSON is well-formed
- Check that values are being written
-
Monitor IPC communication
- Set breakpoints in Settings UI’s
DefaultSndMSGCallBack - Set breakpoints in Runner’s message dispatcher
- Log JSON messages being sent/received
- Set breakpoints in Settings UI’s
-
Check module’s
set_config- Verify module receives configuration
- Check JSON parsing logic
- Ensure settings are applied to module state
-
Review logs
- Settings UI logs:
%LOCALAPPDATA%\Microsoft\PowerToys\logs\Settings\ - Runner logs:
%LOCALAPPDATA%\Microsoft\PowerToys\logs\ - Module logs: Look for module-specific log files
- Settings UI logs:
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