### Run Niri with NixGL Source: https://niri-wm.github.io/niri/Getting-Started.html Runs the Niri binary using NixGL for environments not on NixOS. ```bash nix run --impure github:guibou/nixGL -- ./results/bin/niri ``` -------------------------------- ### Build Niri Source: https://niri-wm.github.io/niri/Getting-Started.html Builds the Niri project in release mode. ```bash cargo build --release ``` -------------------------------- ### NixOS Build and Run Source: https://niri-wm.github.io/niri/Getting-Started.html Builds Niri using Nix and runs the resulting binary. ```bash nix build ./results/bin/niri ``` -------------------------------- ### Spawning Processes at Startup Source: https://niri-wm.github.io/niri/Configuration%3A-Miscellaneous.html Examples of how to spawn processes when niri starts. ```niri-config spawn-at-startup "waybar" spawn-at-startup "alacritty" ``` -------------------------------- ### Arch Linux Installation Source: https://niri-wm.github.io/niri/Getting-Started.html Commands to install Niri and related packages on Arch Linux. ```bash sudo pacman -Syu niri xwayland-satellite xdg-desktop-portal-gnome xdg-desktop-portal-gtk alacritty dms-shell-niri matugen cava qt6-multimedia-ffmpeg systemctl --user add-wants niri.service dms ``` -------------------------------- ### Ubuntu Installation Source: https://niri-wm.github.io/niri/Getting-Started.html Commands to install Niri and DankMaterialShell on Ubuntu 25.10 and above. ```bash sudo add-apt-repository ppa:avengemedia/danklinux sudo add-apt-repository ppa:avengemedia/dms sudo apt install niri dms ``` -------------------------------- ### Fedora Installation Source: https://niri-wm.github.io/niri/Getting-Started.html Commands to install Niri with DankMaterialShell on Fedora. ```bash sudo dnf copr enable avengemedia/dms sudo dnf install niri dms systemctl --user add-wants niri.service dms ``` -------------------------------- ### Fedora Dependencies Source: https://niri-wm.github.io/niri/Getting-Started.html Installs the necessary dependencies for building Niri on Fedora. ```bash sudo dnf install gcc libudev-devel libgbm-devel libxkbcommon-devel wayland-devel libinput-devel dbus-devel systemd-devel libseat-devel pipewire-devel pango-devel cairo-gobject-devel clang libdisplay-info-devel ``` -------------------------------- ### At Startup Matcher Example Source: https://niri-wm.github.io/niri/Configuration%3A-Layer-Rules.html Example of a layer rule that applies only during the first 60 seconds after niri starts, setting opacity to 0.5. ```config layer-rule { match at-startup=true opacity 0.5 } ``` -------------------------------- ### Running Shell Commands at Startup Source: https://niri-wm.github.io/niri/Configuration%3A-Miscellaneous.html Example of running a shell command when niri starts. ```niri-config // Pass all arguments in the same string. spawn-sh-at-startup "qs -c ~/source/qs/MyAwesomeShell" ``` -------------------------------- ### Ubuntu 24.04 Dependencies Source: https://niri-wm.github.io/niri/Getting-Started.html Installs the necessary dependencies for building Niri on Ubuntu 24.04. ```bash sudo apt-get install -y gcc clang libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev libseat-dev libpipewire-0.3-dev libpango1.0-dev libdisplay-info-dev ``` -------------------------------- ### Applying rules at startup Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Example of a window rule that applies only during the first 60 seconds after niri starts, useful for initial monitor placement. ```kdl // Open windows on the HDMI-A-1 monitor at niri startup, but not afterwards. window-rule { match at-startup=true open-on-output "HDMI-A-1" } ``` -------------------------------- ### open-focused Example (Enable) Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Example of how to set `open-focused` to `true` to focus a window, even if normally it wouldn't get auto-focused. ```niri-wm config // Always focus the KeePassXC-Browser unlock dialog. // // This dialog opens parented to the KeePassXC window rather than the browser, // so it doesn't get auto-focused by default. window-rule { match app-id=r#"^org\.keepassxc\.KeePassXC$" title="^Unlock Database - KeePassXC$" open-focused true } ``` -------------------------------- ### Spawn Action Example Source: https://niri-wm.github.io/niri/Configuration%3A-Key-Bindings.html Examples of using the 'spawn' action to run programs, including arguments. ```niri-config binds { // Run alacritty. Mod+T { spawn "alacritty"; } // Run `wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+`. XF86AudioRaiseVolume { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1+"; } } ``` -------------------------------- ### Build with Dinit Integration Source: https://niri-wm.github.io/niri/Getting-Started.html Builds Niri with dinit integration, disabling default systemd integration. ```bash cargo build --release --no-default-features --features dinit,dbus,xdp-gnome-screencast ``` -------------------------------- ### open-fullscreen Example (Enable) Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Example of how to use `open-fullscreen` to make a window open in fullscreen mode. ```niri-wm config window-rule { open-fullscreen true } ``` -------------------------------- ### spawn-sh examples Source: https://niri-wm.github.io/niri/Configuration%3A-Key-Bindings.html Examples demonstrating the use of `spawn-sh` for running shell commands with various shell features like variables, tilde expansion, and process substitution. ```niri-config binds { // Works with spawn-sh: all arguments in the same string. Mod+D { spawn-sh "alacritty -e /usr/bin/fish"; } // Works with spawn-sh: shell variable ($MAIN_OUTPUT), ~ expansion. Mod+T { spawn-sh "grim -o $MAIN_OUTPUT ~/screenshot.png"; } // Works with spawn-sh: process substitution. Mod+Q { spawn-sh "notify-send clipboard \"$(wl-paste)\"" ;} // Works with spawn-sh: multiple commands. Super+Alt+S { spawn-sh "pkill orca || exec orca"; } } ``` -------------------------------- ### Wev Output Example Source: https://niri-wm.github.io/niri/Configuration%3A-Key-Bindings.html Example output from the `wev` tool, used to detect XKB key names. ```text [14: wl_keyboard] key: serial: 757775; time: 44940343; key: 113; state: 1 (pressed) sym: Left (65361), utf8: '' [14: wl_keyboard] key: serial: 757776; time: 44940432; key: 113; state: 0 (released) sym: Left (65361), utf8: '' [14: wl_keyboard] key: serial: 757777; time: 44940753; key: 114; state: 1 (pressed) sym: Right (65363), utf8: '' [14: wl_keyboard] key: serial: 757778; time: 44940846; key: 114; state: 0 (released) sym: Right (65363), utf8: '' ``` -------------------------------- ### open-floating Example (Enable) Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Example of how to use `open-floating` to make a window open in the floating layout. ```niri-wm config // Open the Firefox picture-in-picture window as floating. window-rule { match app-id="firefox$" title="^Picture-in-Picture$" open-floating true } ``` -------------------------------- ### Basic Key Bindings Example Source: https://niri-wm.github.io/niri/Configuration%3A-Key-Bindings.html An example demonstrating how to declare key bindings in the `binds {}` section of the configuration file. ```config binds { Mod+Left { focus-column-left; } Super+Alt+L { spawn "swaylock"; } } ``` -------------------------------- ### Example Usage of niri-ipc Source: https://niri-wm.github.io/niri/src/niri_ipc/lib.rs.html?search= This example shows how to use the niri-ipc crate to communicate with the niri compositor. ```rust 1//! Types for communicating with niri via IPC. 2//! 3//! After connecting to the niri socket, you can send [`Request`]s. Niri will process them one by 4//! one, in order, and to each request it will respond with a single [`Reply`], which is a `Result` 5//! wrapping a [`Response`]. 6//! 7//! If you send a [`Request::EventStream`], niri will *stop* reading subsequent [`Request`]s, and 8//! will start continuously writing compositor [`Event`]s to the socket. If you'd like to read an 9//! event stream and write more requests at the same time, you need to use two IPC sockets. 10//! 11//!
12//! 13//! Requests are *always* processed separately. Time passes between requests, even when sending 14//! multiple requests to the socket at once. For example, sending [`Request::Workspaces`] and 15//! [`Request::Windows`] together may not return consistent results (e.g. a window may open on a 16//! new workspace in-between the two responses). This goes for actions too: sending 17//! [`Action::FocusWindow`] and [Action::CloseWindow] { id: None } together may close 18//! the wrong window because a different window got focused in-between these requests. 19//! 20//!
21//! 22//! You can use the [`socket::Socket`] helper if you're fine with blocking communication. However, 23//! it is a fairly simple helper, so if you need async, or if you're using a different language, 24//! you are encouraged to communicate with the socket manually. 25//! 26//! 1. Read the socket filesystem path from [`socket::SOCKET_PATH_ENV`] (`$NIRI_SOCKET`). 27//! 2. Connect to the socket and write a JSON-formatted [`Request`] on a single line. You can follow 28//! up with a line break and a flush, or just flush and shutdown the write end of the socket. 29//! 3. Niri will respond with a single line JSON-formatted [`Reply`]. 30//! 4. You can keep writing [`Request`]s, each on a single line, and read [`Reply`]s, also each on a 31//! separate line. 32//! 5. After you request an event stream, niri will keep responding with JSON-formatted [`Event`]s, 33//! on a single line each. 34//! 35//! ## Backwards compatibility 36//! 37//! This crate follows the niri version. It is **not** API-stable in terms of the Rust semver. In 38//! particular, expect new struct fields and enum variants to be added in patch version bumps. 39//! 40//! Use an exact version requirement to avoid breaking changes: 41//! 42//! ```toml 43//! [dependencies] 44//! niri-ipc = "=26.4.0" 45//! ``` 47//! 48//! ## Features 49//! 50//! This crate defines the following features: 51//! - `json-schema`: derives the [schemars](https://lib.rs/crates/schemars) `JsonSchema` trait for 52//! the types. 53//! - `clap`: derives the clap CLI parsing traits for some types. Used internally by niri itself. 54 #![warn(missing_docs)] 55 56use std::collections::HashMap; 57use std::str::FromStr; 58use std::time::Duration; 59 60use serde::{Deserialize, Serialize}; 61 62pub mod socket; 63pub mod state; 64 65/// Request from client to niri. 66#[derive(Debug, Serialize, Deserialize, Clone)] 67#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))] 68pub enum Request { 69 /// Request the version string for the running niri instance. 70 Version, 71 /// Request information about connected outputs. 72 Outputs, 73 /// Request information about workspaces. 74 Workspaces, 75 /// Request information about open windows. 76 Windows, 77 /// Request information about layer-shell surfaces. 78 Layers, 79 /// Request information about the configured keyboard layouts. 80 KeyboardLayouts, 81 /// Request information about the focused output. 82 FocusedOutput, 83 /// Request information about the focused window. 84 FocusedWindow, 85 /// Request picking a window and get its information. 86 PickWindow, 87 /// Request picking a color from the screen. 88 PickColor, 89 /// Perform an action. 90 Action(Action), 91 /// Change output configuration temporarily. 92 /// 93 /// The configuration is changed temporarily and not saved into the config file. If the output 94 /// configuration subsequently changes in the config file, these temporary changes will be 95 /// forgotten. 96 Output { 97 /// Output name. 98 output: String, 99 /// Configuration to apply. 100 action: OutputAction, 101 }, 102 /// Start continuously receiving events from the compositor. 103 /// 104 /// The compositor should reply with `Reply::Ok(Response::Handled)`, then continuously send 105 /// [`Event`]s, one per line. 106 /// 107 /// The event stream will always give you the full current state up-front. For example, the 108 /// first workspace-related event you will receive will be [`Event::WorkspacesChanged`] 109 /// containing the full current workspaces state. You *do not* need to separately send ``` -------------------------------- ### open-on-output Example Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Example of how to use `open-on-output` to direct a window to a specific monitor. It also shows how to exclude specific window titles and use different output identifiers. ```niri-wm config // Open Firefox and Telegram (but not its Media Viewer) // on a specific monitor. window-rule { match app-id="firefox$" match app-id=r#"^org\.telegram\.desktop$" # exclude app-id=r#"^org\.telegram\.desktop$" title="^Media viewer$" open-on-output "HDMI-A-1" // Or: // open-on-output "Some Company CoolMonitor 1234" } ``` -------------------------------- ### Niri IPC Client Example Source: https://niri-wm.github.io/niri/src/niri_ipc/lib.rs.html?search= Example of how to create and use a Niri IPC client to send commands. ```rust use niri_ipc::client::NiriClient; fn main() { let client = NiriClient::new().expect("Failed to connect to Niri IPC"); // Example: Send a command to move a window let command = r#"{{ "command": "move_window", "args": {{ "window_id": "12345678", "x": 100, "y": 200 }} }}"#; match client.send_command(command) { Ok(response) => println!("Command successful: {}", response), Err(e) => eprintln!("Command failed: {}", e), } } ``` -------------------------------- ### map() Examples Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search=std%3A%3Avec Examples demonstrating the usage of the map() method on Result. ```rust let line = "1\n2\n3\n4\n"; for num in line.lines() { match num.parse::().map(|i| i * 2) { Ok(n) => println!("{n}"), Err(..) => {} } } ``` -------------------------------- ### open-on-workspace Example Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Example of how to use `open-on-workspace` to make a window open on a specific named workspace. ```niri-wm config // Open Fractal on the "chat" workspace. window-rule { match app-id=r#"^org\.gnome\.Fractal$" open-on-workspace "chat" } ``` -------------------------------- ### open-maximized Example Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Example of how to use `open-maximized` to make a window open in a maximized column. ```niri-wm config // Maximize Firefox by default. window-rule { match app-id="firefox$" open-maximized true } ``` -------------------------------- ### Screen locker configuration example Source: https://niri-wm.github.io/niri/FAQ.html Example of how to configure a screen locker bind to allow unlocking when the screen is already locked. ```kdl binds { Super+Alt+L allow-when-locked=true { spawn "swaylock"; } } ``` -------------------------------- ### open-fullscreen Example (Disable) Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Example of how to set `open-fullscreen` to `false` to prevent a window from opening fullscreen. ```niri-wm config // Make the Telegram media viewer open in windowed mode. window-rule { match app-id=r#"^org\.telegram\.desktop$" title="^Media viewer$" open-fullscreen false } ``` -------------------------------- ### Niri IPC Server Example (Conceptual) Source: https://niri-wm.github.io/niri/src/niri_ipc/lib.rs.html?search= Conceptual example of how a Niri IPC server might handle incoming commands. This is a simplified representation. ```rust use niri_ipc::server::NiriServer; use std::io::{self, BufReader, BufWriter}; use std::net::TcpListener; fn main() -> io::Result<()> { let listener = TcpListener::bind("127.0.0.1:5930")?; println!("Niri IPC server listening on port 5930"); for stream in listener.incoming() { match stream { Ok(stream) => { println!("New connection: {}", stream.peer_addr()?); // Handle connection in a new thread or asynchronously handle_client(stream); } Err(e) => { eprintln!("Connection failed: {}", e); } } } Ok(()) } fn handle_client(stream: std::net::TcpStream) { let mut reader = BufReader::new(stream.try_clone().unwrap()); let mut writer = BufWriter::new(stream); // In a real server, you would read commands, parse them, and execute actions. // This is a placeholder. println!("Handling client..."); // Example: Read a command (simplified) let mut buffer = String::new(); if let Err(e) = io::Read::read_to_string(&mut reader, &mut buffer) { eprintln!("Failed to read command: {}", e); return; } println!("Received command: {}", buffer); // Example: Send a response (simplified) let response = "OK"; if let Err(e) = std::io::Write::write_all(writer.get_mut(), response.as_bytes()) { eprintln!("Failed to send response: {}", e); } if let Err(e) = writer.flush() { eprintln!("Failed to flush writer: {}", e); } } ``` -------------------------------- ### open-maximized-to-edges Example (Enable) Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Example of how to use `open-maximized-to-edges` to make a window open maximized to the edges. ```niri-wm config window-rule { open-maximized-to-edges true } ``` -------------------------------- ### Example Layer Rule Source: https://niri-wm.github.io/niri/Configuration%3A-Layer-Rules.html A comprehensive example demonstrating various matchers and properties for layer rules, including opacity, shadow, background effects, and pop-up configurations. ```config layer-rule { match namespace="waybar" match at-startup=true match layer="top" // Properties that apply continuously. opacity 0.5 block-out-from "screencast" // block-out-from "screen-capture" shadow { on // off softness 40 spread 5 offset x=0 y=5 draw-behind-window true color "#00000064" // inactive-color "#00000064" } geometry-corner-radius 12 place-within-backdrop true baba-is-float true background-effect { xray true blur true noise 0.05 saturation 3 } popups { opacity 0.5 geometry-corner-radius 6 background-effect { xray true blur true noise 0.05 saturation 3 } } } ``` -------------------------------- ### open-focused Example (Disable) Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Example of how to set `open-focused` to `false` to prevent a window from being automatically focused upon opening. ```niri-wm config // Don't give focus to the GIMP startup splash screen. window-rule { match app-id="^gimp" title="^GIMP Startup$" open-focused false } ``` -------------------------------- ### Serve documentation locally with uv Source: https://niri-wm.github.io/niri/Development%3A-Documenting-niri.html Commands to synchronize dependencies and start the local development server for the documentation site. ```bash uv sync uv run mkdocs serve ``` -------------------------------- ### unwrap_err method usage Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Example of using unwrap_err to get the Err value, and an example of it panicking on an Ok. ```rust let x: Result = Ok(2); x.unwrap_err(); // panics with `2` ``` ```rust let x: Result = Err("emergency failure"); assert_eq!(x.unwrap_err(), "emergency failure"); ``` -------------------------------- ### Configure All Output Properties Source: https://niri-wm.github.io/niri/Configuration%3A-Outputs.html Example showing all available properties for an output section, including mode, scale, transform, and hot-corners. ```niri output "eDP-1" { // off mode "1920x1080@120.030" scale 2.0 transform "90" position x=1280 y=0 variable-refresh-rate // on-demand=true focus-at-startup backdrop-color "#001100" hot-corners { // off top-left // top-right // bottom-left // bottom-right } layout { // ...layout settings for eDP-1... } // Custom modes. Caution: may damage your display. // mode custom=true "1920x1080@100" // modeline 173.00 1920 2048 2248 2576 1080 1083 1088 1120 "-hsync" "+vsync" } output "HDMI-A-1" { // ...settings for HDMI-A-1... } output "Some Company CoolMonitor 1234" { // ...settings for CoolMonitor... } ``` -------------------------------- ### Basic include example Source: https://niri-wm.github.io/niri/Configuration%3A-Include.html Demonstrates a simple include statement within a configuration file. ```kdl // Some settings... include "colors.kdl" // Some more settings... ``` -------------------------------- ### unwrap_err() example Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the basic usage of `unwrap_err()` to get the Err value. ```rust let x: Result = Err("emergency failure"); assert_eq!(x.unwrap_err(), "emergency failure"); ``` -------------------------------- ### unwrap_or Example Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Demonstrates using `unwrap_or` to get the Ok value or a default value if the Result is Err. ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` -------------------------------- ### unwrap_or_default method usage Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Example of using unwrap_or_default to get the Ok value or a default value if it's an Err. ```rust let good_year_from_input = "1909"; let bad_year_from_input = "190blarg"; let good_year = good_year_from_input.parse().unwrap_or_default(); let bad_year = bad_year_from_input.parse().unwrap_or_default(); assert_eq!(1909, good_year); assert_eq!(0, bad_year); ``` -------------------------------- ### unwrap method usage Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Basic usage of the unwrap method to get the Ok value, and an example of it panicking on an Err. ```rust let x: Result = Ok(2); assert_eq!(x.unwrap(), 2); ``` ```rust let x: Result = Err("emergency failure"); x.unwrap(); // panics with `emergency failure` ``` -------------------------------- ### Merging example Source: https://niri-wm.github.io/niri/Configuration%3A-Include.html Illustrates how settings are merged between included files and the main configuration. ```kdl // colors.kdl layout { // Does not affect gaps, border width, etc. // Only changes colors as written. focus-ring { active-color "blue" } border { active-color "green" } } ``` ```kdl // config.kdl include "colors.kdl" layout { // Does not set border and focus-ring colors, // so colors from colors.kdl are used. gaps 8 border { width 8 } } ``` -------------------------------- ### Listing DRI Devices Source: https://niri-wm.github.io/niri/Getting-Started.html Command to list available Direct Rendering Manager (DRM) devices, useful for debugging display issues. ```bash $ ls -l /dev/dri/ drwxr-xr-x@ - root 14 мая 07:07 by-path crw-rw----@ 226,0 root 14 мая 07:07 card0 crw-rw----@ 226,1 root 14 мая 07:07 card1 crw-rw-rw-@ 226,128 root 14 мая 07:07 renderD128 crw-rw-rw-@ 226,129 root 14 мая 07:07 renderD129 ``` -------------------------------- ### Kanshi configuration for multiple monitor setups Source: https://niri-wm.github.io/niri/FAQ.html Example Kanshi configuration to manage different output scaling and positioning based on connected monitors. ```kdl profile { output eDP-1 enable scale 1.0 } profile { output HDMI-A-1 enable scale 1.0 position 0,0 output eDP-1 enable scale 1.25 position 1920,0 } ``` -------------------------------- ### Manually Setting Render Device Source: https://niri-wm.github.io/niri/Getting-Started.html Configuration snippet to manually set the render DRM device path in Niri's config file. ```kdl debug { render-drm-device "/dev/dri/renderD128" } ``` -------------------------------- ### Bind screen mirroring with wl-mirror Source: https://niri-wm.github.io/niri/Screencasting.html Configure a keybind to spawn a wl-mirror window for the currently focused output. ```niri binds { Mod+P repeat=false { spawn-sh "wl-mirror $(niri msg --json focused-output | jq -r .name)"; } } ``` -------------------------------- ### as_mut() Example Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Examples demonstrating the usage of the as_mut() method on Result. ```rust fn mutate(r: &mut Result) { match r.as_mut() { Ok(v) => *v = 42, Err(e) => *e = 0, } } let mut x: Result = Ok(2); mutate(&mut x); assert_eq!(x.unwrap(), 42); let mut x: Result = Err(13); mutate(&mut x); assert_eq!(x.unwrap_err(), 0); ``` -------------------------------- ### as_ref() Example Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Examples demonstrating the usage of the as_ref() method on Result. ```rust let x: Result = Ok(2); assert_eq!(x.as_ref(), Ok(&2)); let x: Result = Err("Error"); assert_eq!(x.as_ref(), Err(&"Error")); ``` -------------------------------- ### err() Example Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Examples demonstrating the usage of the err() method on Result. ```rust let x: Result = Ok(2); assert_eq!(x.err(), None); let x: Result = Err("Nothing here"); assert_eq!(x.err(), Some("Nothing here")); ``` -------------------------------- ### Localectl Command Example Source: https://niri-wm.github.io/niri/Configuration%3A-Input.html Illustrates using localectl to set X11 keymap and displays the output of localectl, showing system locale and keymap settings. ```shell $ localectl set-x11-keymap "us" "" "colemak_dh_ortho" "compose:ralt,ctrl:nocaps" $ localectl System Locale: LANG=en_US.UTF-8 LC_NUMERIC=ru_RU.UTF-8 LC_TIME=ru_RU.UTF-8 LC_MONETARY=ru_RU.UTF-8 LC_PAPER=ru_RU.UTF-8 LC_MEASUREMENT=ru_RU.UTF-8 VC Keymap: us-colemak_dh_ortho X11 Layout: us X11 Variant: colemak_dh_ortho X11 Options: compose:ralt,ctrl:nocaps ``` -------------------------------- ### ok() Example Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Examples demonstrating the usage of the ok() method on Result. ```rust let x: Result = Ok(2); assert_eq!(x.ok(), Some(2)); let x: Result = Err("Nothing here"); assert_eq!(x.ok(), None); ``` -------------------------------- ### Example of setting and overriding window rules Source: https://niri-wm.github.io/niri/Configuration%3A-Window-Rules.html Demonstrates how to set a global rule and then override it for a specific application. ```HOCON // Set open-maximized to true for all windows. window-rule { open-maximized true } // Then, for Alacritty, set open-maximized back to false. window-rule { match app-id="Alacritty" open-maximized false } ``` -------------------------------- ### is_err_and() Example Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Examples demonstrating the usage of the is_err_and() method on Result. ```rust use std::io::{Error, ErrorKind}; let x: Result = Err(Error::new(ErrorKind::NotFound, "!")); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), true); let x: Result = Err(Error::new(ErrorKind::PermissionDenied, "!")); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false); let x: Result = Ok(123); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false); let x: Result = Err("ownership".to_string()); assert_eq!(x.as_ref().is_err_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` -------------------------------- ### is_err() Example Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Examples demonstrating the usage of the is_err() method on Result. ```rust let x: Result = Ok(-3); assert_eq!(x.is_err(), false); let x: Result = Err("Some error message"); assert_eq!(x.is_err(), true); ``` -------------------------------- ### is_ok_and() Example Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Examples demonstrating the usage of the is_ok_and() method on Result. ```rust let x: Result = Ok(2); assert_eq!(x.is_ok_and(|x| x > 1), true); let x: Result = Ok(0); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Err("hey"); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Ok("ownership".to_string()); assert_eq!(x.as_ref().is_ok_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` -------------------------------- ### Binds override example Source: https://niri-wm.github.io/niri/Configuration%3A-Include.html Shows how `binds` sections override previously defined conflicting keys. ```kdl // binds.kdl binds { Mod+T { spawn "alacritty"; } } ``` ```kdl // config.kdl include "binds.kdl" binds { // Overrides Mod+T from binds.kdl. Mod+T { spawn "foot"; } } ``` -------------------------------- ### is_ok() Example Source: https://niri-wm.github.io/niri/niri_ipc/type.Reply.html?search= Examples demonstrating the usage of the is_ok() method on Result. ```rust let x: Result = Ok(-3); assert_eq!(x.is_ok(), true); let x: Result = Err("Some error message"); assert_eq!(x.is_ok(), false); ``` -------------------------------- ### Configuring Cursor Theme and Size Source: https://niri-wm.github.io/niri/Configuration%3A-Miscellaneous.html Example of setting the cursor theme and size. ```niri-config cursor { xcursor-theme "breeze_cursors" xcursor-size 48 } ``` -------------------------------- ### Run X11 applications with xwayland-run Source: https://niri-wm.github.io/niri/Xwayland.html Use xwayland-run to automatically manage the lifecycle of a rootful Xwayland server for specific X11 applications. ```bash xwayland-run -- your-x11-app ``` ```bash xwayland-run -geometry 800x600 -fullscreen -- wine wingame.exe ``` -------------------------------- ### Namespace Matcher Example Source: https://niri-wm.github.io/niri/Configuration%3A-Layer-Rules.html Example of a layer rule that matches surfaces with a namespace containing 'waybar'. ```config layer-rule { match namespace="waybar" } ``` -------------------------------- ### Window rule inclusion example Source: https://niri-wm.github.io/niri/Configuration%3A-Include.html Demonstrates how window rules are inserted at the position of the include statement. ```kdl // rules.kdl window-rule { match app-id="Alacritty" open-maximized false } ``` ```kdl // config.kdl window-rule { open-maximized true } // Window rules get inserted at this position. include "rules.kdl" window-rule { match app-id="firefox$" open-maximized true } ``` ```kdl window-rule { open-maximized true } // Included from rules.kdl. window-rule { match app-id="Alacritty" open-maximized false } window-rule { match app-id="firefox$" open-maximized true } ``` -------------------------------- ### Set Output Focus at Startup Source: https://niri-wm.github.io/niri/Configuration%3A-Outputs.html Configure an output to receive focus by default when Niri starts. If multiple outputs have this setting, they are prioritized by their order in the configuration. ```niri // Focus HDMI-A-1 by default. output "HDMI-A-1" { focus-at-startup } // ...if HDMI-A-1 wasn't connected, focus DP-2 instead. output "DP-2" { focus-at-startup } ``` -------------------------------- ### Example of including a border configuration Source: https://niri-wm.github.io/niri/Configuration%3A-Include.html This snippet shows how to configure the border in a separate KDL file, including the necessary 'on' directive. ```kdl // separate.kdl layout { border { // Add this line: on width 4 active-color "#ffc87f" inactive-color "#505050" } } ``` -------------------------------- ### Build with Tracy profiler Source: https://niri-wm.github.io/niri/Development%3A-Developing-niri.html Compile niri with Tracy integration for performance analysis. ```bash cargo build --release --features=profile-with-tracy-ondemand ``` ```bash cargo build --release --features=profile-with-tracy ```