Overview
You will learn
- How to build layouts from scratch
- How to add configurable features to layouts
- How to use modifiers and combinators for composition
This section teaches you to build custom layouts for Shoji. By the end, you’ll understand how layouts work and have the skills to create your own.
Prerequisites
Before starting:
- Shoji installed and running (Installation)
- Basic Lua knowledge (variables, functions, tables)
- A text editor for writing Lua files
The tutorials
Part 1: Your first layout
Build a simple column layout from scratch. You’ll learn the layout protocol and how Shoji uses layouts to position windows.
What you’ll build: A layout that arranges windows in equal vertical columns.
Time: Follow along at your own pace.
Part 2: Making it configurable
Extend your layout to respond to user actions. Add capabilities that let users adjust the main ratio and number of master windows.
What you’ll build: A master-stack layout with adjustable regions.
Prerequisites: Complete Part 1.
Part 3: Modifiers and composition
Transform existing layouts without rewriting them. Use modifiers and combinators to create layout variations.
What you’ll build: Custom modifiers and composed layouts.
Prerequisites: Complete Part 2.
Reference material
After completing the tutorials, use these references (also in this section):
- Layout protocol — Full protocol specification
- Modifiers — Built-in modifiers documentation
- Chaining modifiers — Combining multiple modifiers
Testing your work
Throughout these tutorials, you’ll test layouts in Hammerspoon:
- Save your layout file
- Reload Hammerspoon from the menu bar (Reload config) or run
hs.reload()in the Hammerspoon console - Cycle to your layout (Ctrl+Alt+Space)
- Check the console for errors (menu bar > Console)
Keep the console open while developing to catch errors early.