Plugin types
Draconis++ supports two types of plugins:- InfoProvider: Provides structured data (weather, media, Docker stats, etc.)
- OutputFormat: Adds new output formats (JSON, YAML, Markdown, etc.)
Creating an info provider plugin
Info provider plugins supply structured information that can be displayed in the UI, serialized to JSON, or used in compact format templates.Basic plugin structure
Using the plugin cache
ThePluginCache provides efficient BEVE-based caching:
Creating an output format plugin
Output format plugins allow custom serialization of system data:yaml_plugin.hpp
yaml_plugin.cpp
Building plugins
Dynamic plugin build
Create ameson.build for your plugin:
Static plugin build
For precompiled/static builds, defineDRAC_STATIC_PLUGIN_BUILD:
Plugin configuration
Plugins can read configuration from the plugin config directory:Plugin installation
Plugins are discovered from standard search paths: Linux/macOS:/usr/local/lib/draconis++/plugins/usr/lib/draconis++/plugins~/.local/lib/draconis++/plugins./plugins(current directory)
%LOCALAPPDATA%\draconis++\plugins%APPDATA%\draconis++\plugins%USERPROFILE%\.config\draconis++\plugins.\plugins(current directory)
Testing your plugin
Create a test program:Best practices
- Use the cache: Always check the cache before making expensive queries
- Handle errors gracefully: Return proper error codes and messages
- Document dependencies: Clearly specify what your plugin requires
- Version your plugin: Use semantic versioning
- Test on all platforms: Ensure cross-platform compatibility
- Minimize allocations: Use move semantics and avoid unnecessary copies
- Thread safety: Make your plugin thread-safe if needed
Next steps
- Review platform implementation for OS-specific code
- Explore the plugin API reference
- Check out example plugins in the official repository