From c996ae3d525c43d383ac6d5349eb1641696a2871 Mon Sep 17 00:00:00 2001 From: Chun Wang Date: Sun, 10 May 2026 06:40:20 +0100 Subject: [PATCH] Add configurable hot-corner actions Allow hot corners to run any bind action while preserving the existing overview behavior for bare corner names and the default top-left hot corner. Wire pointer hot-corner entry through normal action dispatch and document both global and per-output configuration. Signed-off-by: Chun Wang --- docs/wiki/Configuration:-Gestures.md | 22 ++++- docs/wiki/Configuration:-Outputs.md | 18 +++- docs/wiki/Gestures.md | 5 +- docs/wiki/Overview.md | 4 +- niri-config/src/gestures.rs | 131 +++++++++++++++++++++++++-- niri-config/src/lib.rs | 49 ++++++++-- resources/default-config.kdl | 11 ++- src/input/mod.rs | 12 ++- src/layout/mod.rs | 2 +- src/niri.rs | 39 ++++---- 10 files changed, 246 insertions(+), 47 deletions(-) diff --git a/docs/wiki/Configuration:-Gestures.md b/docs/wiki/Configuration:-Gestures.md index 24e2b2aec3..72cae3f45e 100644 --- a/docs/wiki/Configuration:-Gestures.md +++ b/docs/wiki/Configuration:-Gestures.md @@ -27,6 +27,11 @@ gestures { // top-right // bottom-left // bottom-right + + // You can also run a custom action instead of toggling the overview. + // top-right { + // power-off-monitors + // } } } ``` @@ -85,8 +90,9 @@ gestures { Since: 25.05 -Put your mouse at the very top-left corner of a monitor to toggle the overview. +Put your mouse at a hot corner of a monitor to run an action. Also works during drag-and-dropping something. +By default, the top-left hot corner toggles the overview. `off` disables the hot corners. @@ -101,6 +107,7 @@ gestures { Since: 25.11 You can choose specific hot corners by name: `top-left`, `top-right`, `bottom-left`, `bottom-right`. If no corners are explicitly set, the top-left corner will be active by default. +Bare corner names toggle the overview for compatibility with previous versions. ```kdl // Enable the top-right and bottom-right hot corners. @@ -112,4 +119,17 @@ gestures { } ``` +You can set a hot corner to run any bind action by putting exactly one action inside its block. + +```kdl +// Power off monitors when the pointer enters the top-right hot corner. +gestures { + hot-corners { + top-right { + power-off-monitors + } + } +} +``` + You can also customize hot corners per-output [in the output config](./Configuration:-Outputs.md#hot-corners). diff --git a/docs/wiki/Configuration:-Outputs.md b/docs/wiki/Configuration:-Outputs.md index 73a022011e..d0ec8b5133 100644 --- a/docs/wiki/Configuration:-Outputs.md +++ b/docs/wiki/Configuration:-Outputs.md @@ -22,6 +22,11 @@ output "eDP-1" { // top-right // bottom-left // bottom-right + + // You can also run a custom action instead of toggling the overview. + // top-right { + // power-off-monitors + // } } layout { @@ -286,7 +291,9 @@ output "HDMI-A-1" { Customize the hot corners for this output. By default, hot corners [in the gestures settings](./Configuration:-Gestures.md#hot-corners) are used for all outputs. -Hot corners toggle the overview when you put your mouse at the very corner of a monitor. +Hot corners run an action when you put your mouse at the very corner of a monitor. +Bare corner names toggle the overview for compatibility with previous versions. +A corner block with exactly one action runs that action instead. `off` will disable the hot corners on this output, and writing specific corners will enable only those hot corners on this output. @@ -305,6 +312,15 @@ output "DP-2" { off } } + +// Power off monitors from the top-right hot corner on eDP-1. +output "eDP-1" { + hot-corners { + top-right { + power-off-monitors + } + } +} ``` ### Layout config overrides diff --git a/docs/wiki/Gestures.md b/docs/wiki/Gestures.md index 5c94d71f79..d279c546bc 100644 --- a/docs/wiki/Gestures.md +++ b/docs/wiki/Gestures.md @@ -91,9 +91,10 @@ This will bring a floating window to the top for example. In the overview, you can also hold the mouse over a workspace to switch to it. -#### Hot Corner to Toggle the Overview +#### Hot Corners Since: 25.05 -Put your mouse at the very top-left corner of a monitor to toggle the overview. +Put your mouse at a hot corner of a monitor to run its configured action. +By default, the top-left hot corner toggles the overview. Also works during drag-and-dropping something. diff --git a/docs/wiki/Overview.md b/docs/wiki/Overview.md index f9bb94a3f5..5af0570a53 100644 --- a/docs/wiki/Overview.md +++ b/docs/wiki/Overview.md @@ -11,7 +11,7 @@ https://github.com/user-attachments/assets/379a5d1f-acdb-4c11-b36c-e85fd91f0995 -Open it with the `toggle-overview` bind, via the top-left hot corner, or using a touchpad four-finger swipe up. +Open it with the `toggle-overview` bind, via the default top-left hot corner, or using a touchpad four-finger swipe up. While in the overview, all keyboard shortcuts keep working, while pointing devices get easier: - Mouse: left click and drag windows to move them, right click and drag to scroll workspaces left/right, scroll to switch workspaces (no holding Mod required). @@ -25,7 +25,7 @@ While in the overview, all keyboard shortcuts keep working, while pointing devic > Put your bar on the *top* layer. Drag-and-drop will scroll the workspaces up/down in the overview, and will activate a workspace when holding it for a moment. -Combined with the hot corner, this lets you do a mouse-only DnD across workspaces. +Combined with the default hot corner, this lets you do a mouse-only DnD across workspaces.