Skip to main content

Overview

Switch event bindings are declared in the switch-events {} section of the config. They allow you to react to hardware events like laptop lid close/open and tablet mode changes.
The syntax is similar to key bindings. Currently, only the spawn action is supported.
In contrast to key bindings, switch event bindings are always executed, even when the session is locked.

Lid Events

lid-close

This event triggers when the laptop lid is closed.

lid-open

This event triggers when the laptop lid is opened.
Niri will already automatically turn the internal laptop monitor on and off in accordance with the laptop lid, so you don’t need to handle that manually.

Tablet Mode Events

tablet-mode-on

This event triggers when a convertible laptop goes into tablet mode. In tablet mode, the keyboard and mouse are usually inaccessible, so you can use this event to activate the on-screen keyboard.

tablet-mode-off

This event triggers when a convertible laptop goes out of tablet mode.
The commands in these examples are just examples. You will need to provide your own on-screen keyboard, such as:

Example Configurations

Automatic Screen Lock on Lid Close

Toggle On-Screen Keyboard

Adjust Display Brightness

Send Notifications

Notes

Always Executed

Switch events run even when your session is locked, so you can use them for critical system functions.

Spawn Only

Currently, only the spawn action is supported for switch events. Other actions from key bindings are not available.

Automatic Monitor Handling

Niri automatically handles turning the laptop monitor on/off based on lid state.

Hardware Dependent

These events depend on your hardware. Not all laptops support all events.