[tip & trick] Picom and @include

Picom supports @include for modular config files

Not sure how many people know this, but picom has an @include directive that lets you split your config into separate files per application.


The idea

Instead of stuffing all window rules into one file, picom supports @include directives. You keep a lean main config and put per-app rules in separate small files. Easy to read, easy to tweak.


The folder structure

~/.config/picom/
├── configs/
│   └── mabox-jaskier.conf       ← main picom config
└── include/
    ├── mabox-rules.conf          ← master rules file
    ├── kitty.conf
    ├── geany.conf
    ├── volbar.conf
    └── ...                       ← one file per app

How it works

Step 1 — At the bottom of your main picom config, include the rules file:

@include "mabox-rules.conf";

Picom looks for included files relative to the config, or in ~/.config/picom/include/.

Step 2 — In mabox-rules.conf, you open a rules: block and include each app config inside it:

rules: (
    {
        @include "kitty.conf"
    },
    {
        @include "geany.conf"
    },
)

Step 3 — Each app file contains just its match rule and settings:

# kitty.conf
match = "class_g = 'kitty'";
blur-background = false;
opacity = 1.0;
dim = 0.0;
animations = (
    {
      triggers = ["open"];
      preset = "fly-in";
      direction = "down";
      duration = 0.5;
    },
)

https://man.archlinux.org/man/picom.1

When @include directive is used in the config file, picom will first search for the included file in the parent directory of picom.conf, then in $XDG_CONFIG_HOME/picom/include/, then in $XDG_CONFIG_DIRS/picom/include.

This git has examples of configs to get a better idea.

:penguin: have fun…

2 Likes