plugin/

directory
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: MIT

README

Internal Plugin System

This directory contains the built-in plugin system for Tinct. Built-in plugins are compiled directly into the main tinct binary and provide core functionality that all users have access to by default.

Overview

The plugin system allows Tinct to be extended with:

  • Input plugins - Extract or generate colour palettes from various sources
  • Output plugins - Apply palettes to applications, generate configs, or control devices
Built-in vs External Plugins
Aspect Built-in (internal/) External (contrib/)
Distribution Compiled into tinct binary Separate downloads
Language Go only Any language
Performance Direct function calls (fastest) Process spawn (~8ms RPC or ~52ms JSON-stdio)
Installation Included by default Via tinct plugins add
Location internal/plugin/ contrib/plugins/
Examples image, hyprland, kitty random, wob, templater

Directory Structure

internal/plugin/
├── README.md                  # This file
├── input/                     # Built-in input plugins
│   ├── image/                 # Extract from images
│   ├── file/                  # Load from files
│   ├── remotejson/            # Fetch from JSON URLs
│   ├── remotecss/             # Extract from CSS
│   └── shared/                # Shared utilities
│       └── regions/           # Ambient region extraction
├── output/                    # Built-in output plugins
│   ├── alacritty/             # Alacritty terminal
│   ├── dunst/                 # Dunst notifications
│   ├── fuzzel/                # Fuzzel launcher
│   ├── hyprland/              # Hyprland WM
│   ├── hyprlock/              # Hyprlock screen locker
│   ├── hyprpaper/             # Hyprpaper wallpaper manager
│   ├── kitty/                 # Kitty terminal
│   ├── neovim/                # Neovim editor
│   ├── swayosd/               # SwayOSD on-screen display
│   ├── waybar/                # Waybar status bar
│   ├── wofi/                  # Wofi launcher
│   ├── zellij/                # Zellij multiplexer
│   ├── common/                # Shared utilities
│   ├── template/              # Template engine
│   └── testing/               # Testing utilities
├── manager/                   # Plugin management
├── executor/                  # Plugin execution (RPC, JSON-stdio)
├── protocol/                  # Plugin protocols and interfaces
└── repository/                # Plugin repository management

Plugin Interfaces

Input Plugin Interface

Input plugins extract or generate colour palettes.

Required Methods:

type Plugin interface {
    Name() string                              // Plugin identifier
    Description() string                       // Human-readable description
    Generate(ctx, opts) (*colour.Palette, error)  // Extract/generate colours
    RegisterFlags(cmd *cobra.Command)          // Register CLI flags
    Validate() error                           // Validate configuration
}

Optional Interfaces:

type WallpaperProvider interface {
    WallpaperPath() string  // Return wallpaper file path
}

type ThemeHinter interface {
    ThemeHint() string  // Suggest "dark", "light", or "auto"
}

See: Input Plugins Documentation

Output Plugin Interface

Output plugins generate configuration files or perform actions with palettes.

Required Methods:

type Plugin interface {
    Name() string                              // Plugin identifier
    Description() string                       // Human-readable description
    Generate(palette) (map[string][]byte, error)  // Generate config files
    RegisterFlags(cmd *cobra.Command)          // Register CLI flags
    Validate() error                           // Validate configuration
    DefaultOutputDir() string                  // Default config directory
}

Optional Interfaces:

type VerbosePlugin interface {
    SetVerbose(bool)  // Receive verbose flag
}

type PreExecuteHook interface {
    PreExecute(ctx) (skip bool, reason string, err error)  // Pre-generation checks
}

type PostExecuteHook interface {
    PostExecute(ctx, execCtx, files) error  // Post-generation actions
}

type WallpaperContextProvider interface {
    SetWallpaperContext(string)  // Receive wallpaper path
}

type TemplateProvider interface {
    GetEmbeddedFS() interface{}  // Expose embedded templates
}

See: Output Plugins Documentation

Creating Built-in Plugins

When to Create a Built-in Plugin

Create a built-in plugin when:

  • The functionality is essential for most users
  • Performance is critical (direct function calls vs process spawn)
  • Deep integration with Tinct core is needed
  • The application is extremely popular (kitty, hyprland, etc.)

Create an external plugin when:

  • The functionality is niche or experimental
  • The application is less common
  • You want to support non-Go languages
  • Distribution as a separate download is acceptable
Adding a New Built-in Output Plugin
  1. Create plugin directory:

    mkdir -p internal/plugin/output/myapp
    cd internal/plugin/output/myapp
    
  2. Create plugin implementation (myapp.go):

    package myapp
    
    import (
        "github.com/jmylchreest/tinct/internal/colour"
        "github.com/spf13/cobra"
    )
    
    type Plugin struct {
        outputDir string
        verbose   bool
    }
    
    func New() *Plugin {
        return &Plugin{}
    }
    
    func (p *Plugin) Name() string {
        return "myapp"
    }
    
    func (p *Plugin) Description() string {
        return "Generate themes for MyApp"
    }
    
    func (p *Plugin) RegisterFlags(cmd *cobra.Command) {
        cmd.Flags().StringVar(&p.outputDir, "myapp.output-dir", p.DefaultOutputDir(), "Output directory")
    }
    
    func (p *Plugin) Validate() error {
        return nil
    }
    
    func (p *Plugin) DefaultOutputDir() string {
        return "~/.config/myapp"
    }
    
    func (p *Plugin) SetVerbose(v bool) {
        p.verbose = v
    }
    
    func (p *Plugin) Generate(palette *colour.CategorisedPalette) (map[string][]byte, error) {
        // Generate config content
        return map[string][]byte{
            "tinct.conf": []byte("# Generated by Tinct"),
        }, nil
    }
    
  3. Add embedded template (optional):

    import "embed"
    
    //go:embed templates/*.tmpl
    var templatesFS embed.FS
    
    func (p *Plugin) GetEmbeddedFS() interface{} {
        return templatesFS
    }
    
  4. Register plugin in internal/cli/generate.go:

    import "github.com/jmylchreest/tinct/internal/plugin/output/myapp"
    
    func init() {
        // ... existing plugins ...
        registerOutputPlugin(myapp.New())
    }
    
  5. Add README (internal/plugin/output/myapp/README.md):

    • Describe what the plugin does
    • List configuration options
    • Provide usage examples
    • Document any special requirements
  6. Test the plugin:

    go build ./cmd/tinct
    ./tinct generate -i image -p wallpaper.jpg -o myapp --verbose
    
Adding a New Built-in Input Plugin

Similar process, but implement the input plugin interface. See existing plugins in internal/plugin/input/ for examples.

Plugin Architecture

Plugin Manager (manager/)

Handles plugin discovery, loading, and lifecycle management.

Key Responsibilities:

  • Register built-in plugins
  • Load external plugins
  • Manage enabled/disabled state
  • Resolve plugin dependencies
Plugin Executor (executor/)

Executes external plugins using different protocols.

Supported Protocols:

  • go-plugin RPC - Process reuse, ~8ms overhead
  • JSON-stdio - Simple, any language, ~52ms overhead
Plugin Protocol (protocol/)

Defines interfaces and data structures for plugin communication.

Key Types:

  • PluginInfo - Plugin metadata
  • PaletteData - Colour palette with metadata
  • InputOptions - Input plugin options
  • ExecutionContext - Execution environment

Template System

Built-in output plugins use Go's text/template engine with custom functions.

Available in templates:

  • get . "role" - Get colour by role
  • has . "role" - Check if role exists
  • hex - Format as #RRGGBB
  • rgb - Format as R, G, B
  • rgba - Format as R, G, B, A
  • hsl - Format as H, S%, L%
  • withAlpha colour alpha - Set alpha channel
  • themeType . - Get theme type (dark/light)
  • .WallpaperPath - Wallpaper path (if available)

See: Template Guide

Testing

Unit Tests

Each plugin should have unit tests:

# Test specific plugin
go test ./internal/plugin/output/myapp/...

# Test all plugins
go test ./internal/plugin/...
Integration Tests

Test with actual Tinct commands:

# Test plugin end-to-end
./tinct generate -i image -p testdata/sample.jpg -o myapp --dry-run --verbose
Test Utilities

Use internal/plugin/output/shared/testing for test helpers:

import "github.com/jmylchreest/tinct/internal/plugin/output/shared/testing"

func TestPlugin(t *testing.T) {
    palette := testing.NewTestPalette()
    plugin := New()
    files, err := plugin.Generate(palette)
    // assertions...
}

Documentation

Each plugin directory should have:

README.md - Plugin overview and usage
Code comments - Document exported functions
Examples - Sample configurations
Templates - Document template variables (if applicable)

Contributing

When adding or modifying built-in plugins:

  1. Follow existing patterns - Match the style of existing plugins
  2. Add comprehensive documentation - README + code comments
  3. Include tests - Unit tests for core functionality
  4. Use templates - Leverage the template system for configs
  5. Handle errors gracefully - Return meaningful error messages
  6. Support dry-run - Don't write files in dry-run mode
  7. Implement optional interfaces - PreExecute, PostExecute, etc. when needed

Resources

Questions?

  • Check existing plugin implementations in this directory
  • Read the comprehensive development guide in docs/DEVELOPMENT.md
  • Open an issue on GitHub for clarification
  • See PLUGINS-WISHLIST.md for requested plugins

Directories

Path Synopsis
Package executor provides a unified interface for executing plugins regardless of their underlying protocol (go-plugin RPC or JSON-stdio).
Package executor provides a unified interface for executing plugins regardless of their underlying protocol (go-plugin RPC or JSON-stdio).
Package input provides the interface and base types for input plugins.
Package input provides the interface and base types for input plugins.
file
Package file provides an input plugin for loading colour palettes from files or manual specifications.
Package file provides an input plugin for loading colour palettes from files or manual specifications.
googlegenai
Package googlegenai provides an input plugin for generating images using Google's Imagen models.
Package googlegenai provides an input plugin for generating images using Google's Imagen models.
image
Package image provides an input plugin for extracting colour palettes from images.
Package image provides an input plugin for extracting colour palettes from images.
markdown
Package markdown provides an input plugin for loading themes from markdown theme files.
Package markdown provides an input plugin for loading themes from markdown theme files.
openrouter
Package openrouter provides an input plugin for generating images using OpenRouter.ai models.
Package openrouter provides an input plugin for generating images using OpenRouter.ai models.
remotecss
Package remotecss provides an input plugin for fetching colour palettes from remote CSS sources.
Package remotecss provides an input plugin for fetching colour palettes from remote CSS sources.
remotejson
Package remotejson provides an input plugin for fetching colour palettes from remote JSON sources with JSONPath queries.
Package remotejson provides an input plugin for fetching colour palettes from remote JSON sources with JSONPath queries.
shared/aiflags
Package aiflags provides shared flags for AI image generation plugins.
Package aiflags provides shared flags for AI image generation plugins.
shared/commonflags
Package commonflags provides shared unprefixed flags for input plugins.
Package commonflags provides shared unprefixed flags for input plugins.
shared/imagecolours
Package imagecolours provides shared helpers for extracting colour palettes from images and saving generation metadata.
Package imagecolours provides shared helpers for extracting colour palettes from images and saving generation metadata.
shared/palettebuilder
Package palettebuilder provides shared helpers for building colour palettes from map[string]string colour sources with optional role-mapping support.
Package palettebuilder provides shared helpers for building colour palettes from map[string]string colour sources with optional role-mapping support.
shared/regions
Package regions provides utilities for extracting colors from specific.
Package regions provides utilities for extracting colors from specific.
shared/seed
Package seed provides utilities for deterministic seed generation for k-means clustering.
Package seed provides utilities for deterministic seed generation for k-means clustering.
Package manager provides plugin management with configuration support.
Package manager provides plugin management with configuration support.
Package output provides the interface and base types for output plugins.
Package output provides the interface and base types for output plugins.
alacritty
Package alacritty provides an output plugin for Alacritty terminal colour themes.
Package alacritty provides an output plugin for Alacritty terminal colour themes.
awww
Package awww provides an output plugin for awww (An Answer to your Wayland Wallpaper Woes) wallpaper daemon.
Package awww provides an output plugin for awww (An Answer to your Wayland Wallpaper Woes) wallpaper daemon.
dunst
Package dunst provides an output plugin for Dunst notification daemon colour themes.
Package dunst provides an output plugin for Dunst notification daemon colour themes.
fuzzel
Package fuzzel provides an output plugin for Fuzzel application launcher colour themes.
Package fuzzel provides an output plugin for Fuzzel application launcher colour themes.
ghostty
Package ghostty provides an output plugin for Ghostty terminal emulator colour themes.
Package ghostty provides an output plugin for Ghostty terminal emulator colour themes.
gnome-shell
Package gnomeshell provides an output plugin for GNOME Shell theming.
Package gnomeshell provides an output plugin for GNOME Shell theming.
gtk3
Package gtk3 provides an output plugin for GTK3 application theming.
Package gtk3 provides an output plugin for GTK3 application theming.
gtk4
Package gtk4 provides an output plugin for GTK4 application theming.
Package gtk4 provides an output plugin for GTK4 application theming.
histui
Package histui provides an output plugin for histui notification daemon CSS themes.
Package histui provides an output plugin for histui notification daemon CSS themes.
hyprland
Package hyprland provides an output plugin for Hyprland window manager colour themes.
Package hyprland provides an output plugin for Hyprland window manager colour themes.
hyprlock
Package hyprlock provides an output plugin for Hyprlock screen lock colour themes.
Package hyprlock provides an output plugin for Hyprlock screen lock colour themes.
hyprpaper
Package hyprpaper provides an output plugin for Hyprpaper wallpaper manager configuration.
Package hyprpaper provides an output plugin for Hyprpaper wallpaper manager configuration.
kde-plasma
Package kdeplasma provides an output plugin for KDE Plasma desktop environment theming.
Package kdeplasma provides an output plugin for KDE Plasma desktop environment theming.
kitty
Package kitty provides an output plugin for Kitty terminal colour themes.
Package kitty provides an output plugin for Kitty terminal colour themes.
konsole
Package konsole provides an output plugin for Konsole terminal color themes.
Package konsole provides an output plugin for Konsole terminal color themes.
libadwaita
Package libadwaita provides an output plugin for libadwaita/GNOME application theming.
Package libadwaita provides an output plugin for libadwaita/GNOME application theming.
markdown
Package markdown provides an output plugin for exporting themes to markdown format.
Package markdown provides an output plugin for exporting themes to markdown format.
mc
Package mc provides an output plugin for Midnight Commander (mc) skin themes.
Package mc provides an output plugin for Midnight Commander (mc) skin themes.
neovim
Package neovim provides an output plugin for Neovim colour themes.
Package neovim provides an output plugin for Neovim colour themes.
ptyxis
Package ptyxis provides an output plugin for Ptyxis terminal color palettes.
Package ptyxis provides an output plugin for Ptyxis terminal color palettes.
qt5
Package qt5 provides an output plugin for Qt5 application theming via qt5ct.
Package qt5 provides an output plugin for Qt5 application theming via qt5ct.
qt6
Package qt6 provides an output plugin for Qt6 application theming via qt6ct.
Package qt6 provides an output plugin for Qt6 application theming via qt6ct.
rosec
Package rosec provides an output plugin for rosec-prompt theme configuration.
Package rosec provides an output plugin for rosec-prompt theme configuration.
shared/dbus_kde
Package dbus_kde provides D-Bus helpers for KDE Plasma configuration reload.
Package dbus_kde provides D-Bus helpers for KDE Plasma configuration reload.
shared/testing
Package testing provides shared test utilities for output plugins.
Package testing provides shared test utilities for output plugins.
shared/utils
Package common provides shared utilities for output plugins.
Package common provides shared utilities for output plugins.
swayosd
Package swayosd provides an output plugin for SwayOSD on-screen display colour themes.
Package swayosd provides an output plugin for SwayOSD on-screen display colour themes.
template
Package template provides utilities for loading plugin templates with custom override support.
Package template provides utilities for loading plugin templates with custom override support.
walker
Package walker provides an output plugin for Walker application launcher colour themes.
Package walker provides an output plugin for Walker application launcher colour themes.
waybar
Package waybar provides an output plugin for Waybar status bar colour themes.
Package waybar provides an output plugin for Waybar status bar colour themes.
wbg
Package wbg provides an output plugin for wbg, a simple Wayland wallpaper application.
Package wbg provides an output plugin for wbg, a simple Wayland wallpaper application.
wofi
Package wofi provides an output plugin for Wofi application launcher colour themes.
Package wofi provides an output plugin for Wofi application launcher colour themes.
zellij
Package zellij provides an output plugin for Zellij terminal multiplexer colour themes.
Package zellij provides an output plugin for Zellij terminal multiplexer colour themes.
Package protocol defines the plugin protocol version and compatibility checking.
Package protocol defines the plugin protocol version and compatibility checking.
Package repository provides plugin repository management for Tinct.
Package repository provides plugin repository management for Tinct.
shared
themeformat
Package themeformat provides types and utilities for the markdown theme format.
Package themeformat provides types and utilities for the markdown theme format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL