Skip to content

ruslanlap/PowerToysRun-Definition

Repository files navigation

πŸ” PowerToys Run: Definition Plugin

Definition Plugin Logo

Definition

Lookup word definitions, phonetics, and synonyms directly in PowerToys Run.

Definition Plugin Demo

πŸ“‹ Table of Contents

πŸ“‹ Overview

Definition is a plugin for Microsoft PowerToys Run that allows you to quickly lookup word definitions, phonetics, and synonyms without leaving your keyboard. Simply type def <word> to fetch definitions from dictionaryapi.dev.

Lookup word definitions

✨ Features

  • πŸ” Instant Definitions: Get definitions in real-time via dictionaryapi.dev.
  • πŸ”Š Pronunciation Audio: Play phonetic audio directly from your results.
  • πŸ“š Phonetics & Synonyms: View phonetic spelling, synonyms, and antonyms.
  • πŸ“ Usage Examples: See real-world examples of how words are used.
  • βš™οΈ Fully Configurable: JSON-based configuration with 11+ customizable settings.
  • ⏱️ Delayed Execution: Shows loading indicator before fetching results.
  • πŸ’Ύ Smart Caching: In-memory cache for repeat lookups with configurable size and expiration.
  • πŸ”„ Robust Network Handling: Exponential backoff retry logic for reliable API calls.
  • πŸŒ“ Theme Awareness: Automatically switches icons for light/dark mode.
  • πŸ“‹ Rich Context Menu: Copy definitions, play pronunciation, open source URL, or search for related words.
  • πŸ”„ Cancellable Requests: Automatically cancels previous requests when typing new queries.
  • 🌐 Wiktionary Integration: Open any word in Wiktionary for additional information and translations.

🎬 Demo

Definition Plugin Demo

πŸš€ Installation

Prerequisites

  • PowerToys Run installed (v0.70.0 or later)
  • Windows 10 (build 22621) or later
  • .NET 9.0 Runtime (included with Windows 11 22H2 or later)
  • Internet connection (for API access)

Quick Install

  1. Download the appropriate ZIP for your system architecture:

  2. Extract the ZIP to:

    %LOCALAPPDATA%\Microsoft\PowerToys\PowerToys Run\Plugins\
    

    Typical path: C:\Users\YourUsername\AppData\Local\Microsoft\PowerToys\PowerToys Run\Plugins\

  3. Restart PowerToys (right-click the PowerToys icon in the system tray and select "Restart").

  4. Open PowerToys Run (Alt + Space) and type def <word>.

Manual Verification

To verify the plugin is correctly installed:

  1. Open PowerToys Settings
  2. Navigate to PowerToys Run > Plugins
  3. Look for "Definition" in the list of plugins
  4. Ensure it's enabled (toggle should be ON)

πŸ”§ Usage

  1. Activate PowerToys Run (Alt + Space).
  2. Type:
    • def to see instructions.
    • def <word> to lookup definitions.
  3. Press Enter to fetch results.
  4. Use Ctrl + C to copy a definition.
  5. Right-click a result to:
    • Copy definition with Ctrl + C
    • Play pronunciation audio
    • Open the word in Wiktionary
    • Search for related words

βš™οΈ Configuration

The plugin supports extensive customization through a config.json file that's automatically created in the plugin directory. Changes take effect immediately without requiring a restart.

Available Settings

Setting Default Description
CacheMaxSize 100 Maximum number of cached word lookups
HttpTimeoutSeconds 10 Timeout for API requests in seconds
CacheExpirationMinutes 30 How long to keep cache entries
EnableAudioPlayback true Enable/disable pronunciation audio
EnableClipboardOperations true Enable/disable copy to clipboard
TextTruncateLength 30 Maximum text length in context menu
EnableVerboseLogging false Enable detailed debug logging
ApiEndpoint dictionaryapi.dev Dictionary API endpoint
MaxResultsPerMeaning 3 Maximum definitions per word meaning
ShowExamplesInResults true Show usage examples
ShowSynonymsInResults true Show synonyms
ShowAntonymsInResults true Show antonyms

Example Configuration

{
  "CacheMaxSize": 200,
  "HttpTimeoutSeconds": 15,
  "EnableAudioPlayback": true,
  "ShowSynonymsInResults": false,
  "ShowAntonymsInResults": false,
  "ShowExamplesInResults": true,
  "MaxResultsPerMeaning": 2,
  "EnableVerboseLogging": true
}

πŸ“ Data Storage

All settings are stored in the standard PowerToys settings file (no additional data files created).

πŸ› οΈ Building from Source

git clone https://github.com/ruslanlap/PowerToysRun-Definition.git
cd PowerToysRun-Definition/Definition
dotnet build
# To package:
dotnet publish -c Release -r win-x64 --output ./publish
zip -r Definition-v1.2.1-x64.zip ./publish

πŸ“Š Project Structure

PowerToysRun-Definition/
β”œβ”€β”€ data/                            # Plugin assets (icons, demos)
β”‚   β”œβ”€β”€ definition.dark.png
β”‚   β”œβ”€β”€ definition.logo.png
β”‚   β”œβ”€β”€ demo-definition.gif
β”‚   └── demo-definition-2.gif
β”œβ”€β”€ Definition/                      # Plugin source
β”‚   β”œβ”€β”€ Community.PowerToys.Run.Plugin.Definition/
β”‚   β”‚   β”œβ”€β”€ Images/
β”‚   β”‚   β”‚   β”œβ”€β”€ definition.dark.png
β”‚   β”‚   β”‚   └── definition.light.png
β”‚   β”‚   β”œβ”€β”€ Main.cs
β”‚   β”‚   └── plugin.json
β”‚   └── Community.PowerToys.Run.Plugin.Definition.csproj
└── README.md

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Please make sure to update tests as appropriate.

Contributors

❓ FAQ

Does the plugin require internet access?

Yes, the plugin needs internet access to fetch definitions from dictionaryapi.dev. Results are cached in memory for subsequent lookups of the same word.

How do I change the plugin's theme?

The plugin automatically adapts to your PowerToys theme (light/dark). Icons are dynamically loaded based on your current system theme.

Are definitions cached?

Yes, definitions are cached in memory during the current session (up to 100 entries) to improve performance and reduce API calls.

Can I customize the dictionary source?

Not in the current version, but this may be added in future updates. The plugin currently uses dictionaryapi.dev exclusively.

Why does the plugin show "Looking up..." before showing results?

The plugin implements IDelayedExecutionPlugin which shows a loading indicator while fetching results from the API. This provides immediate feedback while the request is processing.

How do I play the pronunciation audio?

Right-click on any definition result and select "Play Pronunciation" from the context menu (only available if the API provides audio for that word).

How can I see more information about a word?

Right-click on any result and select "Open Source URL in Browser" to view the word in Wiktionary, which provides additional information, translations, and etymology.

πŸ”† Feature Spotlight

This section highlights some of the most powerful features of the Definition plugin:

Wiktionary Integration Wiktionary Integration - Access comprehensive word information by opening any word in Wiktionary directly from the context menu. Get access to additional meanings, translations, etymologies, and related terms. Advanced Context Menu Rich Context Menu - The plugin offers a powerful context menu with multiple actions. Copy definitions, play pronunciation audio, open source URLs, and search for related words. Right-click on any result to access these features.

πŸ§‘β€πŸ’» Tech Stack

Technology Description
C# / .NET 9.0 Primary language and runtime
PowerToys Run API IPlugin, IDelayedExecutionPlugin, IContextMenu interfaces
HttpClient API requests with timeout handling
System.Text.Json JSON parsing
WPF MediaPlayer Audio playback
System.Threading Asynchronous operations
GitHub Actions CI/CD with multi-architecture builds

🌐 Localization

Currently, the plugin UI is in English. Localization support is planned for future releases.

πŸ“Έ Screenshots

Word Definition Word Definition Phonetics Display Phonetics Display Context Menu Context Menu Antonyms Feature Antonyms Feature Audio Pronunciation Audio Pronunciation Delayed Execution Delayed Execution

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgements

β˜• Support

If you find this plugin useful and would like to support its development, you can buy me a coffee:

Buy me a coffee

πŸ†• What's New (v1.2.1)

  • βš™οΈ Fully Configurable Settings β€” JSON-based configuration system with runtime updates:
    • config.json with 11 customizable settings
    • Toggle synonyms, antonyms, examples display
    • Configure cache size, timeouts, and result limits
    • Enable/disable audio playback and clipboard operations
    • Settings reload automatically without restart
  • πŸ”„ Robust Network Retry Logic β€” Enhanced reliability for API calls:
    • Exponential backoff with smart retry conditions
    • Handles transient network errors gracefully
    • Configurable retry attempts and delays
  • πŸ› οΈ Improved Clipboard Operations β€” Better threading and reliability:
    • Custom STA task scheduler for thread safety
    • Enhanced error handling and timeout protection
    • Configurable clipboard operations enable/disable
  • πŸ”§ Configuration Bug Fix β€” Settings now actually work:
    • Fixed issue where config.json changes were ignored
    • All configuration options now properly respected
    • Dynamic reloading ensures immediate effect
  • πŸ“Š Enhanced Debugging β€” Better troubleshooting capabilities:
    • Verbose logging option for detailed diagnostics
    • Improved error reporting throughout the plugin
    • Better network error categorization

Made with ❀️ by ruslanlap