Class LayerList
Every layer surface on every output, as wm.layers. Layer surfaces are panels, wallpapers, launchers and notifications.
Implements: List<Layer>
all()andget()go output by output.- A layer is in the list from the moment the app makes it, before it has drawn anything, until it closes.
- The lookups below return new plain tables.
lua
for _, bar in ipairs(wm.layers:namespace("waybar")) do
print(bar.output and bar.output.name, bar.size)
endMethods
wm.layers:namespace(name: string) -> Layer[]namespace
The layers whose namespace is exactly name. Several layers can share one.
wm.layers:depth(depth: "background" | "bottom" | "top" | "overlay") -> Layer[]depth
The layers at one depth, on every output.
Errors for any other depth.
lua
local has_overlay = #wm.layers:depth("overlay") > 0wm.layers:on_output(name: string) -> Layer[]on_output
The layers on the output called name.
- Empty for an unknown name.
lua
local layers_here = wm.layers:on_output(output.name)wm.layers:under(point: Point) -> Layer?under
The frontmost layer at point, in global coordinates: overlay first, then top, bottom and background.
- nil when no layer is there.
- Windows don't count, so a layer behind a window is still found.
wm.input:target_undergives what the pointer would hit.
lua
local under_pointer = wm.layers:under(pointer:position())wm.layers:on(event: "new_layer", fn: function) -> functionon
The other layer events are on each Layer.
Errors for any other event name.
Events
Listen with wm.layers:on(name, fn), which returns a function that stops listening.
"new_layer" (layer: Layer)new_layer
An app made a layer surface. It has no size yet: wait for first_content.
- After each load of the config, it fires once for every layer that already exists. Per-layer listeners only need adding here.
lua
wm.layers:on("new_layer", function(layer)
local function refresh()
print("layers changed on", layer.output and layer.output.name)
end
layer:on("first_content", refresh)
layer:on("changed", refresh)
layer:on("closed", refresh)
end)