niri-switch implements fast task switching for the niri compositor. It aims to provide functionality similar to the Alt-Tab known from Windows, Gnome, KDE Plasma and many other desktop environments.
The main use case is quickly switching between windows located on different displays and/or workspaces.
niri-switch is currently usable and quite stable. It is still in early development and requires a few features to be completed to actually deliver a good user experience. But anyone is welcome to play around with it and provide much appreciated feedback.
niri - niri-switch needs a running niri session to connect to it via IPC socket.gtk4, gtk4-layer-shell - needed to display the graphical interface. The minimal required version of GTK4 is 4.12.To install the program you will also need cargo - the Rust build system. It's usually installed via rustup.
Clone the repository and run cargo install --path ./niri-switch.
Make sure that ~/.cargo/bin is in your $PATH. You can verify it by running niri-switch --version.
Next you need to add the following configuration to your niri config at ~/.config/niri/config.kdl:
spawn-at-startup "niri-switch-daemon"
binds {
// Append to existing binds section
Alt+Tab { spawn "niri-switch"; }
}
After restarting the niri session, niri-switch will be ready to use.
[!NOTE] You can bind the command to any key combination,
Alt+Tabis just an example.[!TIP] Instead of
spawn-at-startup, you can write a custom systemd service forgraphical-session.targetif you want more control over the daemon.
After opening the overlay (e.g. via Alt + Tab), you can move around with arrow keys and select a window with Enter. To exit without focusing on any window, press Escape.
Repeated calls to niri-switch will also advance the selection.
To enable switching to the previous window (similar to Alt+Shift+Tab in other environments), add another keybinding to your niri config using the --previous option.
binds {
// Append this line to the existing binds section
Alt+Shft+Tab { spawn "niri-switch" "--previous"; }
}
niri-switch is based on GTK4 and will use your system's default GTK settings. The config is usually located at ~/.config/gtk-4.0/settings.ini and can be modified. For example, if you want to use a dark theme in niri-switch without any CSS modification, you can add
[Settings]
gtk-application-prefer-dark-theme = true
to the settings.ini file (this will have a global effect). Or run the niri-switch-daemon with GTK_THEME environment variable.
You can customize the look by providing custom ~/.config/niri-switch/style.css file. The default configuration is located in src/daemon/gui/style.css. You can copy and modify it.
To examine the CSS classes and the widget hierarchy, you can run the daemon with debug flag: GTK_DEBUG=interactive niri-switch-daemon and play around in the inspector.
GTK supports only a specific subset of CSS properties. You can learn more about it in GTK documentation.
The configuration is loaded at the daemon startup in this order:
$XDG_CONFIG_HOME/niri-switch/style.css - if the environment variable is set and file exists.$HOME/.config/niri-switch/style.css - if the above does not exist or environment variable is not set.src/daemon/gui/style.css - if none of the above exist or required variables are not set.Some very useful materials when working with GTK4 and zbus in Rust: * GUI development with Rust and GTK 4 * zbus: D-Bus for Rust made easy
$ claude mcp add niri-switch \
-- python -m otcore.mcp_server <graph>