Skip to content

Configuration: Outputs

github-actions[bot] edited this page Sep 3, 2024 · 11 revisions

Overview

By default, niri will attempt to turn on all connected monitors using their preferred modes. You can disable or adjust this with output sections.

Here's what it looks like with all properties written out:

output "eDP-1" {
    // off
    mode "[email protected]"
    scale 2.0
    transform "90"
    position x=1280 y=0
    variable-refresh-rate // on-demand=true
    background-color "#003300"
}

output "HDMI-A-1" {
    // ...settings for HDMI-A-1...
}

output "Some Company CoolMonitor 1234" {
    // ...settings for CoolMonitor...
}

Outputs are matched by connector name (i.e. eDP-1, HDMI-A-1), or by monitor manufacturer, model, and serial, separated by a single space each. You can find all of these by running niri msg outputs.

Usually, the built-in monitor in laptops will be called eDP-1.

Since: 0.1.6 The output name is case-insensitive.

Since: 0.1.9 Outputs can be matched by manufacturer, model, and serial. Before, they could be matched only by the connector name.

off

This flag turns off that output entirely.

// Turn off that monitor.
output "HDMI-A-1" {
    off
}

mode

Set the monitor resolution and refresh rate.

The format is <width>x<height> or <width>x<height>@<refresh rate>. If the refresh rate is omitted, niri will pick the highest refresh rate for the resolution.

If the mode is omitted altogether or doesn't work, niri will try to pick one automatically.

Run niri msg outputs while inside a niri instance to list all outputs and their modes. The refresh rate that you set here must match exactly, down to the three decimal digits, to what you see in niri msg outputs.

// Set a high refresh rate for this monitor.
// High refresh rate monitors tend to use 60 Hz as their preferred mode,
// requiring a manual mode setting.
output "HDMI-A-1" {
    mode "[email protected]"
}

// Use a lower resolution on the built-in laptop monitor
// (for example, for testing purposes).
output "eDP-1" {
    mode "1280x720"
}

scale

Set the scale of the monitor.

Since: 0.1.6 If scale is unset, niri will guess an appropriate scale based on the physical dimensions and the resolution of the monitor.

Since: 0.1.7 You can use fractional scale values, for example scale 1.5 for 150% scale.

Since: 0.1.7 Dot is no longer needed for integer scale, for example you can write scale 2 instead of scale 2.0.

Since: 0.1.7 Scale below 0 and above 10 will now fail during config parsing. Scale was previously clamped to these values anyway.

output "eDP-1" {
    scale 2.0
}

transform

Rotate the output counter-clockwise.

Valid values are: "normal", "90", "180", "270", "flipped", "flipped-90", "flipped-180" and "flipped-270". Values with flipped additionally flip the output.

output "HDMI-A-1" {
    transform "90"
}

position

Set the position of the output in the global coordinate space.

This affects directional monitor actions like focus-monitor-left, and cursor movement. The cursor can only move between directly adjacent outputs.

Note

Output scale and rotation has to be taken into account for positioning: outputs are sized in logical, or scaled, pixels. For example, a 3840×2160 output with scale 2.0 will have a logical size of 1920×1080, so to put another output directly adjacent to it on the right, set its x to 1920. If the position is unset or results in an overlap, the output is instead placed automatically.

output "HDMI-A-1" {
    position x=1280 y=0
}

Automatic Positioning

Niri repositions outputs from scratch every time the output configuration changes (which includes monitors disconnecting and connecting). The following algorithm is used for positioning outputs.

  1. Collect all connected monitors and their logical sizes.
  2. Sort them by their name. This makes it so the automatic positioning does not depend on the order the monitors are connected. This is important because the connection order is non-deterministic at compositor startup.
  3. Try to place every output with explicitly configured position, in order. If the output overlaps previously placed outputs, place it to the right of all previously placed outputs. In this case, niri will also print a warning.
  4. Place every output without explicitly configured position by putting it to the right of all previously placed outputs.

variable-refresh-rate

Since: 0.1.5

This flag enables variable refresh rate (VRR, also known as adaptive sync, FreeSync, or G-Sync), if the output supports it.

You can check whether an output supports VRR in niri msg outputs.

Note

Some drivers have various issues with VRR.

If the cursor moves at a low framerate with VRR, try setting the disable-cursor-plane debug flag and reconnecting the monitor.

If a monitor is not detected as VRR-capable when it should, sometimes unplugging a different monitor fixes it.

Some monitors will continuously modeset (flash black) with VRR enabled; I'm not sure if there's a way to fix it.

output "HDMI-A-1" {
    variable-refresh-rate
}

Since: 0.1.9 You can also set the on-demand=true property, which will only enable VRR when this output shows a window matching the variable-refresh-rate window rule. This is helpful to avoid various issues with VRR, since it can be disabled most of the time, and only enabled for specific windows, like games or video players.

output "HDMI-A-1" {
    variable-refresh-rate on-demand=true
}

background-color

Since: 0.1.8

Set the background color that niri draws for this output. This is visible when you're not using any background tools like swaybg.

The alpha channel for this color will be ignored.

output "HDMI-A-1" {
    background-color "#003300"
}