Layout Templates - MorgenWM

Deutsche Version

Layout Templates

Layout templates let you define a frame layout, including which programs to spawn into each frame, in a TOML file, then apply it with a single command or keybinding. They're useful for setting up a development workspace, a monitoring dashboard, or any repeatable multi-window arrangement.

Where templates live

Template files go in:

~/.config/morgenwm/templates/<name>.toml

setup.sh installs the example templates from example/templates/ into this directory. You can create your own or edit the examples.

Template format

A template is a flat list of [[frame]] entries. Each frame has an id and is either a leaf (holds windows) or a split (contains two child frames). Splits reference their children by left and right id.

FieldTypeApplies toDescription
idstringallUnique identifier for this frame
parentstringallParent split id; empty for the root
typestringall"leaf" or "split"
directionstringsplits"horizontal" (left-right) or "vertical" (top-bottom)
ratiofloatsplitsFirst child's share, 0.0–1.0 (default 0.5)
leftstringsplitsId of the left/top child
rightstringsplitsId of the right/bottom child
commandstringleavesShell command(s) to spawn into this frame. Use \| to put multiple windows in the same frame
requires_filepathbooltemplateIf true, prompt for a working directory via fuzzel before creating the layout. The path is available as $MOGENWM_TEMPLATE_DIR in commands

Example

┌─────────────────────┐
│                     │
│  editor (foot) │  70%
│                     │
├──────────┬──────────┤
│ terminal │ browser  │  30%
│ (htop)   │ (firefox)│
└──────────┴──────────┘

# ~/.config/morgenwm/templates/dev-layout.toml

[[frame]]
id = "root"
type = "split"
direction = "vertical"
ratio = 0.7
left = "editor"
right = "bottom"

[[frame]]
id = "editor"
type = "leaf"
command = "foot"

[[frame]]
id = "bottom"
type = "split"
direction = "horizontal"
ratio = 0.5
left = "terminal"
right = "browser"

[[frame]]
id = "terminal"
type = "leaf"
command = "foot -e htop"

[[frame]]
id = "browser"
type = "leaf"
command = "firefox"

Applying templates

Via IPC (command line)

morgenwm_msg action apply-template dev-layout

Via keybinding

In config.toml:

[[keybindings]]
key = "t"
modifiers = ["Mod"]
action = "template:dev-layout"

How it works

When a template is applied:

  1. If requires_filepath = true, fuzzel prompts for a working directory. The path is exported as $MOGENWM_TEMPLATE_DIR.
  2. The frame tree is built from the template and replaces the current workspace's root frame.
  3. Each leaf with a command is queued, the next window that opens is placed into that leaf instead of the focused frame. Multiple commands in one leaf (separated by |) all go into the same frame.
  4. Commands are spawned sequentially (300ms apart, via sh -c) so windows arrive in the order the template lists them.

Leaves without a command stay empty, you can manually move windows into them later.

Notes

  • Applying a template replaces the current frame layout entirely. Existing windows in the old layout are not carried over.
  • Use requires_filepath = true and $MOGENWM_TEMPLATE_DIR when programs need a shared working directory. The fuzzel prompt appears once, before any windows are created.