Skip to content

Class Output ​

A monitor, nested Hazel's window, or a virtual output, from wm.outputs.

Two handles to the same output are equal with ==.

Once the output is gone:

  • every property reads nil, and area(), usable_area() and size() return nil
  • modes() returns an empty table
  • setting mode, transform, position or scale does nothing
  • assigning or adding to drawables raises an error

Properties ​

output.name: stringname read only ​

The connector name, such as "eDP-1" or "HDMI-A-1". Nested Hazel's window is "winit", and a virtual output has the name it was given.

  • It doesn't change while the output exists, so save per-output settings under it.

output.description: stringdescription read only ​

A longer name for people, such as "Hazel - Virtual - preview".

output.properties: tableproperties read only ​

What the monitor says about itself.

  • make and model: strings. A virtual output has "Hazel" and "Virtual".
  • size: a Size in millimetres, 0x0 when unknown.
  • subpixel: the subpixel layout, such as "Unknown" or "HorizontalRgb".

output.mode: OutputMode?mode ​

The mode in use. Assign one of output:modes(), or a table with size and an optional refresh, to switch.

  • On a tty it takes the mode with that size and refresh. Without a refresh, the highest one at that size.
  • Under the nested backend it asks the host to resize Hazel's window. The mode changes when the window does.
  • changed fires once the new mode is in use.

Errors on a tty when the monitor has no mode of that size and refresh. Under the nested backend, for a size outside 1x1 to 16384x16384.

lua
local function use_highest_refresh(target)
	local best
	for _, mode in ipairs(target:modes()) do
		if mode.size.width == target:size().width and mode.size.height == target:size().height
			and (not best or mode.refresh > best.refresh) then
			best = mode
		end
	end
	if best and not best.current then target.mode = best end
end
wm.outputs:on("added", use_highest_refresh)

output.transform: "normal" | "90" | "180" | "270" | "flipped" | "flipped_90" | "flipped_180" | "flipped_270"transform ​

How the picture is turned for a rotated or mirrored monitor. Assigning it fires changed.

  • "90", "270", "flipped_90" and "flipped_270" swap the width and height of area().

Errors for any other name. The message lists the valid ones.

output.position: Pointposition ​

The output's top-left corner in global coordinates, the ones windows are placed in. Assigning it moves the output and fires changed.

  • Outputs aren't moved apart for you. Two that overlap show the same part of the layout.
lua
local function place_side_by_side()
	local x = 0
	for _, placed in ipairs(wm.outputs:all()) do
		placed.position = Point(x, 0)
		x = x + placed:area().width
	end
end
place_side_by_side()

output.scale: numberscale ​

How many physical pixels make one logical pixel. Fractions such as 1.25 or 1.5 work.

  • Assigning it changes the size of area() and fires changed. Apps on the output are told the new scale.

Errors outside 0.25 to 8.

output.drawables: DrawableListdrawables ​

Drawables on this output, placed against area(), not the usable area. left = 0, right = 0, top = 0, bottom = 0 covers the whole output.

  • A drawable's layer puts it among the layer surfaces and windows.
  • The list is dropped when the output goes.
lua
local dimmer = Drawable.rect({ left = 0, right = 0, top = 0, bottom = 0, fill = "#00000060", layer = "overlay" })
output.drawables:add(dimmer)
output.drawables:remove(dimmer)

Methods ​

output:modes() -> OutputMode[]modes ​

Every mode the output offers, in a new table each call.

  • Under the nested backend there is one mode: the window's current size.

output:size() -> Size?size ​

The size of the current mode, in physical pixels.

  • nil when there is no mode.

output:area() -> Rect?area ​

Where the output is in global coordinates. Starts at position; the size is the mode's size divided by the scale and turned by the transform.

  • A 2560x1440 mode at scale 1.5 gives a 1707x960 area.

output:usable_area() -> Rect?usable_area ​

area() without the strips that panels reserve along its edges. Place windows inside it so panels don't cover them.

lua
local function maximize_on(target_window, target_output)
	local usable = target_output:usable_area()
	target_window.box.position = Anim.spring(Point(usable.x, usable.y))
	target_window:request_size({ width = usable.width, height = usable.height })
end

output:remove() -> nilremove ​

Removes a virtual output. removed fires first, then its layers are closed and its drawables dropped.

  • Does nothing on an output that is already gone.

Errors for an output that isn't virtual.

lua
local preview = wm.outputs:name("preview")
if preview then preview:remove() end