Niri

From Gentoo Wiki
Jump to:navigation Jump to:search
Resources

Installation

Niri resides in the GURU repository. To enable GURU:

GURU

Using eselect repository

First, emerge git, as well as eselect-repository:

root #emerge --ask dev-vcs/git eselect-repository
root #eselect repository enable guru

More information on app-eselect/eselect-repository can be found in the eselect-repository article.

Manually adding a repos.conf entry

To manually add the GURU repository, simply add the following file:

FILE /etc/portage/repos.conf/guru.conf
[guru]
location = /var/db/repos/guru
sync-type = git
sync-uri = https://github.com/gentoo-mirror/guru.git

More information on repos.conf can be found in the /etc/portage/repos.conf article.

Syncing

Once the GURU repository has been added, all that is left to do is to sync the repository:

root #emerge --sync guru

Or alternatively:

root #emaint sync --repo guru

Emerge

First, unmask Niri:

FILE /etc/portage/package.accept_keywords/niri
gui-wm/niri ~amd64

Emerge Niri:

root #emerge --ask gui-wm/niri

Invocation

To start niri on systemd:

user $niri-session

Openrc:

user $dbus-run-session niri --session

Display Manager

Niri should support most Display Managers, but if on OpenRC, some additional tweaking might be needed.

SDDM should work out of the box with Niri, however, on OpenRC, you must change the .desktop file to not use the "niri-session" binary:

FILE /usr/share/wayland-sessions/niri.desktop
[Desktop Entry]
Name=Niri
Comment=A scrollable-tiling Wayland compositor
# Replaced "niri-session" with "niri --session". You might also wanna add "dbus-run-session" next to it.
Exec=niri --session
Type=Application
DesktopNames=niri

GDM can be used, however it will fallback to x11 if a user is on the Nvidia Proprietary driver and on OpenRC, and will thus be unable to launch a Wayland session. On OpenRC, just like SDDM, you will also need to change the .desktop file to not use "niri-session".

Greetd should work with niri as well, as long as your greeter is properly setup. Below is an example configuration using Tuigreet as the greeter:

FILE /etc/greetd/config.toml
[terminal]
vt = 1

[default_session]
command = "tuigreet --cmd /etc/greetd/niri.sh"
user = "greeter"

The "niri.sh" script should contain the following:

FILE /etc/greetd/niri.sh
#!/bin/bash

# Uncomment the appropriate line based on your init system.

# For systemd:
niri-session

# For OpenRC, use niri --session:
# dbus-run-session niri --session

You may also need to set additional environment variables, depending on your setup.

Sound

PulseAudio, Alsa, etc. should work as sound servers, however PipeWire integrates with Wayland very well. It is also required for screen recording.

PipeWire

First, add the pulseaudio and pipewire USE Flags to make.conf:

FILE /etc/portage/make.conf
USE="pipewire pulseaudio"

Add the sound-server USE Flag to package.use:

FILE /etc/portage/package.use/pipewire
media-video/pipewire sound-server

user services

Users of OpenRC have a couple of options. Enabling gentoo-pipewire-launcher normally from Niri config will work for a singular login, but break after a second login.

There is no known way to restart gentoo-pipewire-launcher from Niri.

Instead OpenRC users should switch to OpenRC >0.60 and enable the PipeWire user service.

Unmask OpenRC:

FILE /etc/portage/package.accept_keywords/openrc
sys-apps/openrc

Unmask pambase:

FILE /etc/portage/package.accept_keywords/pambase
=sys-auth/pambase-20250228-r1 ~amd64

Emerge OpenRC and pambase:

root #emerge --ask sys-apps/openrc sys-auth/pambase

Run the following command to enable user services:

user $mkdir -p ~/.config/rc/runlevels/{boot,default} "$XDG_RUNTIME_DIR/openrc"; echo "default" > $XDG_RUNTIME_DIR/openrc/softlevel; openrc --user

Reboot.

Run the following commands to enable Pipewire user services:

user $rc-update add -U pipewire default
user $rc-update add -U pipewire-pulse default
user $rc-update add -U wireplumber default

Portals

Portals are required for flatpaks to integrate with the desktop. Emerge xdg-desktop-portal and xdg-desktop-portal-gnome, which is required for screen sharing:

root #emerge --ask xdg-desktop-portal xdg-desktop-portal-gnome

Niri must be run with the niri-session script to run portals, either through a display manager or manually.

On OpenRC, this would be

user $dbus-run-session niri --session

Polkit

Polkit is necessary for a user to mount drives in a file manager, such as Nautilus. There are a few choices in polkit authentication agents, but there are some caveats in most.

Gnome polkit is deprecated as it was added to Gnome Shell, and has not received an update in some time.

Plasma polkit works, but will not respect the user's QT theme.

mate polkit

Mate polkit respects the user's GTK theme and has been updated.

First, emerge mate-polkit:

root #emerge --ask mate-polkit

Add the following line to Niri configuration for OpenRC:

FILE ~/.config/niri/config.kdl
spawn-at-startup "/usr/libexec/polkit-mate-authentication-agent-1"

xwayland satellite

Xwayland-satellite is required to run programs like Steam in wayland, if the compositor does not support xwayland natively.

First, emerge xwayland-satellite from GURU:

root #emerge --ask xwayland-satellite

add the following to Niri configuration file:

FILE ~/.config/niri/config.kdl
spawn-at-startup "xwayland-satellite"
environment {
       	DISPLAY ":0"
}

Launch steam with the following command, to launch Steam as a flatpak:

user $env DISPLAY=:0 flatpak run com.valvesoftware.Steam

Dark Mode

Niri reads dark or light theme from Gnome Settings. To change from light to dark mode, write the following command in the terminal:

user $dconf write /org/gnome/desktop/interface/color-scheme '"prefer-dark"'

Application Launcher

The default configuration of Niri supports fuzzel.

Emerge fuzzel from GURU:

root #emerge --ask gui-apps/fuzzel

Fuzzel can be invoked with super+D.

File Manager

By default, Niri uses Nautilus as the file manager.

Emerge Nautilus:

root #emerge --ask gnome-base/nautilus

Wallpaper

There are 2 options for wallpapers on Niri, swaybg and swww.

swww

Unmask swww

FILE /etc/portage.package.accept_keywords/swww
gui-apps/swww ~amd64

start the swww daemon in Niri configuration:

FILE ~/.config/niri/config.kdl
spawn-at-startup "swww-daemon"

select a wallpaper with swww:

user $swww img /path/to/image.png

OBS

OBS allows a user to record their desktop. Some use flags may need to be enabled before OBS can screen share.

FILE /etc/portage/make.confmake.conf file
USE="screencast gstreamer gles2"