Skip to main content

Overview

In this section you can configure input devices like keyboard and mouse, and some input-related options. There’s a section for each device type: keyboard, touchpad, mouse, trackpoint, trackball, tablet, touch. Settings in those sections will apply to every device of that type.
Currently, there’s no way to configure specific devices individually (but that is planned).

Keyboard

Layout

In the xkb section, you can set layout, variant, options, model and rules. These are passed directly to libxkbcommon, which is also used by most other Wayland compositors.
input {
    keyboard {
        xkb {
            layout "us"
            variant "colemak_dh_ortho"
            options "compose:ralt,ctrl:nocaps"
        }
    }
}
See the xkeyboard-config(7) manual for more information on XKB options.
Alternatively, you can directly set a path to a .xkb file containing an xkb keymap. This overrides all other xkb settings.
input {
    keyboard {
        xkb {
            file "~/.config/keymap.xkb"
        }
    }
}
If the xkb section is empty (like it is by default), niri will fetch xkb settings from systemd-localed at org.freedesktop.locale1 over D-Bus.You can see this layout in localectl and change it with localectl set-x11-keymap:
localectl set-x11-keymap "us" "" "colemak_dh_ortho" "compose:ralt,ctrl:nocaps"
localectl
These settings are picked up by some other programs too, like GDM.

Layout Tracking

When using multiple layouts, niri can remember the current layout globally (the default) or per-window.
track-layout
string
default:"global"
Controls how keyboard layouts are tracked:
  • global: layout change is global for all windows
  • window: layout is tracked for each window individually
input {
    keyboard {
        track-layout "window"
    }
}

Repeat Settings

repeat-delay
number
default:"600"
Delay in milliseconds before the keyboard repeat starts
repeat-rate
number
default:"25"
Rate in characters per second
input {
    keyboard {
        repeat-delay 600
        repeat-rate 25
    }
}

Num Lock

Set the numlock flag to turn on Num Lock automatically at startup.
input {
    keyboard {
        numlock
    }
}
You might want to disable (comment out) numlock if you’re using a laptop with a keyboard that overlays Num Lock keys on top of regular keys.

Pointing Devices

Most settings for the pointing devices are passed directly to libinput. Other Wayland compositors also use libinput, so it’s likely you will find the same settings there.
For flags like tap, omit them or comment them out to disable the setting.

Common Settings

A few settings are common between touchpad, mouse, trackpoint, and trackball:
natural-scroll
flag
If set, inverts the scrolling direction
accel-speed
number
default:"0.0"
Pointer acceleration speed. Valid values are from -1.0 to 1.0
accel-profile
string
default:"adaptive"
Can be adaptive (the default) or flat (disables pointer acceleration)
scroll-method
string
When to generate scroll events instead of pointer motion events. Can be:
  • no-scroll
  • two-finger
  • edge
  • on-button-down
The default and supported methods vary depending on the device type.
left-handed
flag
If set, changes the device to left-handed mode
middle-emulation
flag
Emulate a middle mouse click by pressing left and right mouse buttons at once

Touchpad Settings

input {
    touchpad {
        tap
        natural-scroll
        dwt
        accel-speed 0.2
    }
}
tap
flag
Enable tap-to-click
dwt
flag
Disable-when-typing
dwtp
flag
Disable-when-trackpointing
drag
boolean
Controls if tap-and-drag is enabled
drag-lock
flag
If set, lifting the finger off for a short time while dragging will not drop the dragged item.
tap-button-map
string
Can be left-right-middle or left-middle-right. Controls which button corresponds to a two-finger tap and a three-finger tap.
click-method
string
Can be button-areas or clickfinger. Changes the click method.
disabled-on-external-mouse
flag
Do not send events while external pointer device is plugged in
scroll-factor
number
Scales the scrolling speed by this value You can also override horizontal and vertical scroll factor separately:
scroll-factor horizontal=2.0 vertical=-1.0

Mouse Settings

input {
    mouse {
        accel-speed 0.2
        accel-profile "flat"
    }
}
Mouse supports the same common settings as touchpad, plus scroll-factor.

Tablet and Touch Settings

Tablets and touchscreens are absolute pointing devices that can be mapped to a specific output:
input {
    tablet {
        map-to-output "eDP-1"
    }

    touch {
        map-to-output "eDP-1"
    }
}
map-to-output
string
Map the device to a specific output. Valid output names are the same as the ones used for output configuration.
calibration-matrix
float[6]
Set to six floating point numbers to change the calibration matrix.
  • for tablet
  • for touch
When a tablet is not mapped to any output, it will map to the union of all connected outputs, without aspect ratio correction.

General Settings

Disable Power Key Handling

By default, niri will take over the power button to make it sleep instead of power off. Set this if you would like to configure the power button elsewhere (i.e. logind.conf).
input {
    disable-power-key-handling
}

Warp Mouse to Focus

Makes the mouse warp to newly focused windows. Does not make the cursor visible if it had been hidden.
input {
    warp-mouse-to-focus
}
You can customize the warp behavior with the mode property:
mode
string
default:"default"
  • default: warps separately horizontally and vertically
  • center-xy: warps by both X and Y coordinates together
  • center-xy-always: always warps to center, even if mouse was already inside the window
input {
    warp-mouse-to-focus mode="center-xy"
}

Focus Follows Mouse

Focuses windows and outputs automatically when moving the mouse over them.
input {
    focus-follows-mouse
}
You can optionally set max-scroll-amount. Then, focus-follows-mouse won’t focus a window if it will result in the view scrolling more than the set amount. The value is a percentage of the working area width.
input {
    // Allow focus-follows-mouse when it results in scrolling at most 10% of the screen.
    focus-follows-mouse max-scroll-amount="10%"
}
input {
    // Allow focus-follows-mouse only when it will not scroll the view.
    focus-follows-mouse max-scroll-amount="0%"
}

Workspace Auto Back and Forth

Normally, switching to the same workspace by index twice will do nothing (since you’re already on that workspace). If this flag is enabled, switching to the same workspace by index twice will switch back to the previous workspace.
input {
    workspace-auto-back-and-forth
}
Niri will correctly switch to the workspace you came from, even if workspaces were reordered in the meantime.

Modifier Keys

Customize the Mod key for key bindings. Only valid modifiers are allowed, e.g. Super, Alt, Mod3, Mod5, Ctrl, Shift.
mod-key
string
default:"Super"
The modifier key to use for bindings when running niri on a TTY (default: Super)
mod-key-nested
string
default:"Alt"
The modifier key to use for bindings when running niri as a nested window (default: Alt)
// Switch the mod keys around: use Alt normally, and Super inside a nested window.
input {
    mod-key "Alt"
    mod-key-nested "Super"
}
There are a lot of default bindings with Mod, none of them “make it through” to the underlying window. You probably don’t want to set mod-key to Ctrl or Shift, since Ctrl is commonly used for app hotkeys, and Shift is used for regular typing.

Build docs developers (and LLMs) love