Skip to content

Writing Patterns

Patterns are the core of Gtheme’s theming system. This guide walks you through creating a pattern from an existing configuration file.

Step by step

Let’s say you want to theme your kitty terminal. Here’s how to turn a static config into a Gtheme pattern.

  1. Start with the original config

    Take the color-related section of your config file. For kitty, that might be:

    foreground #f8f8f2
    background #1e1f28
    color0 #000000
    color1 #ff5555
  2. Replace hardcoded colors with placeholders

    Swap each hex value with the corresponding Gtheme variable:

    foreground #<[foreground]>
    background #<[background]>
    color0 #<[black]>
    color1 #<[red]>
  3. Add the output-file directive

    Add a line at the very top specifying where the filled file should be written:

    <[output-file]>=~/.config/kitty/colors.conf
  4. Add user settings with fallbacks (optional)

    For values that vary per user (like fonts), use user settings with a fallback:

    font_family <[default-font|JetBrains Mono]>
    font_size <[default-font-size|12]>
  5. Save the pattern

    Save the file as kitty.pattern in your desktop’s gtheme/patterns/ directory.

  6. Enable it

    Add "kitty": true to the actived section of desktop_config.json, or run:

    Terminal window
    gtheme pattern enable kitty
  7. Test it

    Terminal window
    gtheme theme apply Dracula

    Check that ~/.config/kitty/colors.conf was generated with the Dracula colors.

Real-world examples

CSS colors (Waybar)

For CSS-based configs, you might generate CSS custom properties:

<[output-file]>=~/.config/waybar/colors/colors.css
@define-color background #<[background]>;
@define-color on_background #<[foreground]>;
@define-color primary #<[blue]>;
@define-color secondary #<[cyan]>;
@define-color error #<[red]>;

Hyprland variables

For Hyprland, colors use the rgba() format:

<[output-file]>=~/.config/hypr/colors/colors.conf
$primary = rgba(<[blue]>ff)
$on_primary = rgba(<[background]>ff)
$surface = rgba(<[background]>ff)
$on_surface = rgba(<[foreground]>ff)

Rasi format (Rofi)

<[output-file]>=~/.config/rofi/colors.rasi
* {
primary: #<[blue]>;
surface: #<[background]>;
on-surface: #<[foreground]>;
}

Adding a post-script

If the application doesn’t auto-reload when its config changes, create a post-script with the same name. For kitty:

gtheme/post-scripts/kitty.sh
#!/bin/bash
pkill -USR1 kitty
exit 0

Make it executable:

Terminal window
chmod +x gtheme/post-scripts/kitty.sh

Pattern modules

For applications with multiple config files (like Spotify with Spicetify), create a directory:

patterns/
└── spotify/
├── spotify-colors.pattern
└── spotify-theme.pattern

The module name is spotify. Enabling/disabling it affects both sub-patterns.

Tips

  • Check existing patterns — browse the gtheme-desktops repository for real examples.
  • Only template what changes — don’t put your entire config in a pattern. Only include the color-related portions. Use @import, source, or include directives in the main config to pull in the generated color file.
  • Use comments — add <[theme-name]> in a comment at the top so you can tell which theme generated the file.
  • Test with contrasting themes — try a light theme (like One-Light) and a dark theme (like Dracula) to make sure your pattern works well with both.