Note
Since new versions of niri compositor have native Alt+Tab functionality built in, I will no longer maintain this project.
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.
The program is currently usable and quite stable. It still 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 is4.12.
The niri-switch package is available on AUR for Arch-based distributions. You can install it via any AUR wrapper you like (yay, paru etc.). For example:
paru -S niri-switchThis repository provides a flake you can use to install the package.
Show detailed instructions
To install it you must have flake enabled and your NixOS configuration must be managed with flakes. See https://wiki.nixos.org/wiki/Flakes for instructions on how to install and enable them on NixOS.
Next, you can add this flake as inputs in flake.nix in the repository
containing your NixOS configuration:
inputs = {
# ---Snip---
niri-switch= {
url = "github:Kiki-Bouba-Team/niri-switch";
# Optional, by default this flake follows the latest nixpkgs-unstable.
# ---
# Note that setting this will make it follow your version of nixpkgs, which
# can lead to issue if you lock it to nixpkgs stable. If you don't add this
# line, the derivation will be bigger, but will work Out Of the Box.
inputs.nixpkgs.follows = "nixpkgs";
};
# ---Snip---
}Then you can install niri-switch by adding the package provided by this flake in your configuration, for example:
{inputs, pkgs, ...}:
let
inherit (pkgs.stdenv.hostPlatform) system;
in
{
environment.systemPackages = [
inputs.niri-switch.packages.${system}.default
];
}This example only works if you can access inputs as an extra argument in your configuration.
On other distributions you will 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 the installation by running niri-switch --version.
After installation 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+Tab is just an example.
Tip
Instead of spawn-at-startup, you can write a custom systemd service for graphical-session.target if 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+Shift+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.- Embedded
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: