Skip to content

Actions overview

  • How to bind actions to hotkeys
  • What action categories exist
  • How to use layout-specific actions

Actions are operations bound to hotkeys. Shoji ships with built-in actions for navigation, window management, and layout control.

This page explains how actions work. For the canonical list of actions and defaults, see Actions reference.

Use bindHotkeys to assign actions to key combinations:

spoon.Shoji:bindHotkeys({
focus_left = { { "ctrl", "alt" }, "h" },
focus_right = { { "ctrl", "alt" }, "l" },
cycle_layout_forward = { { "ctrl", "alt" }, "space" },
})

Shoji binds default hotkeys automatically when you call start(). See Default keybindings for the full list.

To override defaults, call bindHotkeys before start():

spoon.Shoji:bindHotkeys({
focus_left = { { "ctrl", "alt" }, "h" },
focus_right = { { "ctrl", "alt" }, "l" },
})
spoon.Shoji:start()

Either format works:

-- Standard Spoon format: { modifiers_table, key }
focus_left = { { "ctrl", "alt" }, "h" }
-- Flat format: all strings in one table, key comes last
focus_left = { "ctrl", "alt", "h" }
Modifier Key name
Command "cmd"
Control "ctrl"
Option/Alt "alt"
Shift "shift"
Function "fn"

Pass an empty table to skip binding an action:

spoon.Shoji:bindHotkeys({
focus_left = { { "ctrl", "alt" }, "h" },
focus_right = {}, -- Not bound
})

Some layouts expose their own actions. BSP, for example, provides resize and rotate:

spoon.Shoji:bindHotkeys({
bsp_expand_horizontal = { { "ctrl", "cmd" }, "l" },
bsp_shrink_horizontal = { { "ctrl", "cmd" }, "h" },
bsp_expand_vertical = { { "ctrl", "cmd" }, "j" },
bsp_shrink_vertical = { { "ctrl", "cmd" }, "k" },
bsp_rotate = { { "ctrl", "cmd" }, "r" },
})

Layout actions follow the pattern <layout>_<action>.

spoon.Shoji:unbindHotkeys()

Removes every hotkey binding created by bindHotkeys. Useful for stopping Shoji or switching between keybinding sets.

For the complete list of action names and defaults, see Actions reference.