2024-10-18 16:00:40 +02:00
|
|
|
### Overview
|
|
|
|
|
|
2024-11-03 23:00:18 +03:00
|
|
|
<sup>Since: 0.1.10</sup>
|
|
|
|
|
|
2024-10-18 16:00:40 +02:00
|
|
|
Switch event bindings are declared in the `switch-events {}` section of the config.
|
|
|
|
|
|
|
|
|
|
Here are all the events that you can bind at a glance:
|
|
|
|
|
|
|
|
|
|
```kdl
|
|
|
|
|
switch-events {
|
2024-11-05 09:40:54 +03:00
|
|
|
lid-close { spawn "notify-send" "The laptop lid is closed!"; }
|
|
|
|
|
lid-open { spawn "notify-send" "The laptop lid is open!"; }
|
2024-10-18 16:00:40 +02:00
|
|
|
tablet-mode-on { spawn "bash" "-c" "gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true"; }
|
|
|
|
|
tablet-mode-off { spawn "bash" "-c" "gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false"; }
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The syntax is similar to key bindings.
|
2025-03-15 16:42:05 +01:00
|
|
|
Currently, only the [`spawn` action](./Configuration:-Key-Bindings.md#spawn) are supported.
|
2024-10-18 16:00:40 +02:00
|
|
|
|
|
|
|
|
> [!NOTE]
|
|
|
|
|
> In contrast to key bindings, switch event bindings are *always* executed, even when the session is locked.
|
|
|
|
|
|
|
|
|
|
### `lid-close`, `lid-open`
|
|
|
|
|
|
|
|
|
|
These events correspond to closing and opening of the laptop lid.
|
|
|
|
|
|
2024-11-05 09:40:54 +03:00
|
|
|
Note that niri will already automatically turn the internal laptop monitor on and off in accordance with the laptop lid.
|
2024-10-18 16:00:40 +02:00
|
|
|
|
|
|
|
|
```kdl
|
|
|
|
|
switch-events {
|
2024-11-05 09:40:54 +03:00
|
|
|
lid-close { spawn "notify-send" "The laptop lid is closed!"; }
|
|
|
|
|
lid-open { spawn "notify-send" "The laptop lid is open!"; }
|
2024-10-18 16:00:40 +02:00
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `tablet-mode-on`, `tablet-mode-off`
|
|
|
|
|
|
|
|
|
|
These events trigger when a convertible laptop goes into or out of tablet mode.
|
|
|
|
|
In tablet mode, the keyboard and mouse are usually inaccessible, so you can use these events to activate the on-screen keyboard.
|
|
|
|
|
|
|
|
|
|
```kdl
|
|
|
|
|
switch-events {
|
|
|
|
|
tablet-mode-on { spawn "bash" "-c" "gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true"; }
|
|
|
|
|
tablet-mode-off { spawn "bash" "-c" "gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false"; }
|
|
|
|
|
}
|
|
|
|
|
```
|