Skip to content

Lua events

Events

With hl.on, you can define callbacks on events. You can register as many as you want.

hl.on("window.active", function(w)
  hl.notification.create({ text = "Window focused: " .. w.title, timeout = 5000, icon = "ok" })
end)

Or, if you’re working with events that have multiple parameters:

hl.on("workspace.move_to_monitor", function(ws, m)
  hl.notification.create({
    text = "Workspace: " .. ws.name .. " moved to a monitor at x: " .. m.position.x,
    timeout = 4000,
    icon = "ok"
  })
end)

Event list:

EventDescriptionParameters
config.props_refreshedEmitted when a prop refresh event is executedbool: true if the prop refresh event is being executed as scheduled, false if executed prematurely with the Lua function
config.reloadedEmitted when the config has been reloaded and appliedNone
config.unloadEmitted just before the config is unloaded and Lua state torn down, i.e. on reload or shutdown, to close or save things before they are lostNone
hyprland.shutdownEmitted once before Hyprland exitsNone
hyprland.startEmitted once on startNone
input.keyboard.keyEmitted when a key is pressed or releasedinteger: XKB keycode; integer: Unix timestamp that the event occurred; integer: released (0), pressed (1), or repeated (2)
keybinds.submapEmitted when the active submap changes. An empty string means the default submap was restoredstring: Submap Name
layer.closedEmitted when a layer surface is closedLayerSurface
layer.openedEmitted when a layer surface is openedLayerSurface
monitor.addedEmitted when a monitor is connected and readyMonitor
monitor.focusedEmitted when the active monitor changesMonitor
monitor.layout_changedEmitted when the monitor arrangement changes. This occurs when a monitor is added or removed, a monitor’s resolution or refresh rate is changed, or the config is reloaded with different rulesNone
monitor.removedEmitted when a monitor is disconnected and removedMonitor
screenshare.stateEmitted when a screenshare session starts or stopsBool: Active, Integer: Type, String: Name
window.activeEmitted when the active window changesWindow; int (focus reason)
window.bellEmitted when a window rings the system bell, even if it’s mutedWindow
window.classEmitted when a window class changesWindow
window.closeEmitted when a window is closed. It may still be visible during its closing animationWindow
window.destroyEmitted when a window is removed from the compositor. For windows with a close animation, fires after the animation completesWindow
window.fullscreenEmitted when the fullscreen status of a window changesWindow
window.killEmitted when a window is forcefully killed via hyprctl killWindow
window.minimizeEmitted when a window requests to change its minimized stateWindow; bool: true if requesting minimization, false for unminimization
window.move_to_workspaceEmitted when a window is moved to a different workspaceWindow; Workspace
window.openEmitted when a window is fully initialized with window rules appliedWindow
window.open_earlyEmitted when a window is created and mapped, but before window rules are appliedWindow
window.pinEmitted when a window is pinned or unpinnedWindow
window.titleEmitted when a window title changesWindow
window.update_rulesEmitted when a window’s rules are re-evaluated, e.g. when its title or class changesWindow
window.urgentEmitted when a window requests an urgent stateWindow
workspace.activeEmitted when the active workspace on a monitor changesWorkspace
workspace.createdEmitted when a workspace is createdWorkspace
workspace.move_to_monitorEmitted when a workspace is moved to a different monitorWorkspace; Monitor
workspace.removedEmitted when a workspace is removedWorkspace
workspace.special_activeEmitted when the opened special workspace on a monitor changes. Workspace of nil means no special workspace is openWorkspace; Monitor
Last updated on