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.AisKey.a.
Errors for a name xkb doesn't know.
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.
Point(point: Point | table) -> PointPoint
A copy of a point, or a point from a table.
- The table has
xandy, or two numbers in a row.Point({ x = 1, y = 2 })andPoint({ 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.
sizecan be a table withwidthandheight, or two numbers in a row.
Errors the same way as the four-number form.
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,widthandheight, 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:
Drawable.rect(spec)returns aDrawableRect.Drawable.text(spec)returns aDrawableText.Drawable.image(spec)returns aDrawableImage.Drawable.window(spec)returns aDrawableWindow, a picture of a window.
Functions
print(...: any) -> nilprint
Writes its arguments to Hazel's log instead of standard output.
- The line is
print():followed by each argument throughtostring, separated by tabs. - It is logged at the info level.
print("windows open:", wm.windows:count())