Skip to content

Globals ​

The names every config can use without a require.

Values ​

wm: Wmwm: Wm ​

The compositor: windows, layers, outputs, input and the config's own events.

  • A reload gives the new config a fresh wm. Listeners added by the old config are gone.

Key: table<string, Keysym>Key: table<string, Keysym> ​

Keysyms by their xkb name, such as Key.Return, Key.a, Key.F1 or Key.XF86AudioRaiseVolume. Compare them with a key event's raw_key or key.

  • Case doesn't matter. When a name fits two keysyms the lowercase one wins, so Key.A is Key.a.

Errors for a name xkb doesn't know.

lua
wm.input:on("key", function(event)
	if event.raw_key == Key.Return and event.modifiers.super and event.state == "Pressed" then
		Process.spawn("foot")
	end
end)

Button: table<string, MouseButton>Button: table<string, MouseButton> ​

Mouse buttons by name: Button.Left, Button.Right, Button.Middle, Button.Back and Button.Forward. Compare them with a pointer event's button.

Errors for any other name.

Constructors ​

Point(x: number, y: number) -> PointPoint ​

A point in logical pixels.

lua
local corner = Point(40, 30)
local nudged = corner + Point(0.5, 0)

Point(point: Point | table) -> PointPoint ​

A copy of a point, or a point from a table.

  • The table has x and y, or two numbers in a row. Point({ x = 1, y = 2 }) and Point({ 1, 2 }) are the same.

Rect(x: number, y: number, width: number, height: number) -> RectRect ​

A rectangle in logical pixels.

Errors for a negative width or height, and for a value that isn't finite.

Rect(position: Point, size: Size) -> RectRect ​

A rectangle from its top-left corner and its size.

  • size can be a table with width and height, or two numbers in a row.

Errors the same way as the four-number form.

lua
local area = output:usable_area()
local size = { width = 640, height = 400 }
local centred = Rect(area:center() - Point(size.width / 2, size.height / 2), size)

Rect(rect: Rect | table) -> RectRect ​

A copy of a rect, or a rect from a table.

  • The table has x, y, width and height, or four numbers in a row.

Tables ​

Anim: tableAnim: table ​

Makes animated values: Anim.spring, Anim.tween, Anim.throttle, Anim.delay and Anim.mix.

Timer: tableTimer: table ​

Timers: Timer.after, Timer.every and Timer.now.

Process: tableProcess: table ​

Starts and signals programs: Process.spawn and Process.kill.

Text: tableText: table ​

Text.measure measures text before it is drawn.

Drawable: tableDrawable: table ​

Makes drawables, things Hazel draws for the config:

Functions ​

print(...: any) -> nilprint ​

Writes its arguments to Hazel's log instead of standard output.

  • The line is print(): followed by each argument through tostring, separated by tabs.
  • It is logged at the info level.
lua
print("windows open:", wm.windows:count())