MCPcopy Index your code
hub / github.com/Kiki-Bouba-Team/niri-switch

github.com/Kiki-Bouba-Team/niri-switch @v0.2.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.1 ↗ · + Follow
68 symbols 104 edges 16 files 30 documented · 44%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

niri-switch - A niri task switcher

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.

image

Project status

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.

Dependencies

  • 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.

Getting started

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+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.

Navigation

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"; }
}

Default themes

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.

Customization

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.

Resources

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

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Method 33
Function 21
Class 11
Enum 2
Interface 1

Languages

Rust100%

Modules by API surface

src/daemon/gui/window_list/mod.rs9 symbols
src/daemon/gui/mod.rs9 symbols
src/daemon/gui/store/window_cache.rs8 symbols
src/daemon/gui/store/app_database.rs7 symbols
src/daemon/niri_socket.rs6 symbols
src/daemon/gui/window_list/imp.rs6 symbols
src/daemon/dbus.rs5 symbols
src/daemon/main.rs3 symbols
src/daemon/gui/window_list/window_item/imp.rs3 symbols
src/client/main.rs3 symbols
src/daemon/gui/window_list/window_item/mod.rs2 symbols
src/daemon/gui/style.rs2 symbols

For agents

$ claude mcp add niri-switch \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page