Skip to content

Instantly share code, notes, and snippets.

@DuaneNielsen
Created February 17, 2026 20:08
Show Gist options
  • Select an option

  • Save DuaneNielsen/ed534e89ec61ef89ce7034fc18cfce96 to your computer and use it in GitHub Desktop.

Select an option

Save DuaneNielsen/ed534e89ec61ef89ce7034fc18cfce96 to your computer and use it in GitHub Desktop.
Niri Wayland compositor session setup on Ubuntu 24.04 with NVIDIA

Niri Session Setup on Ubuntu 24.04

Guide to getting niri working properly as a session manager with screen recording support.

Prerequisites

sudo apt install pipewire wireplumber xdg-desktop-portal xdg-desktop-portal-gnome xdg-desktop-portal-gtk

User Groups

Add yourself to video and render groups for GPU access:

sudo usermod -aG video,render $USER

Log out and back in (or reboot) for group changes to take effect.

Systemd User Units

If you built niri from source, the systemd units may not be installed. Create them manually:

~/.config/systemd/user/niri.service

[Unit]
Description=Niri Wayland Compositor
BindsTo=graphical-session.target
Before=graphical-session.target
Wants=graphical-session-pre.target
After=graphical-session-pre.target

[Service]
Type=notify
ExecStart=/usr/local/bin/niri --session
Slice=session.slice
Restart=no

~/.config/systemd/user/niri-shutdown.target

[Unit]
Description=Niri Session Shutdown
DefaultDependencies=no
StopWhenUnneeded=yes

Conflicts=graphical-session.target graphical-session-pre.target
After=graphical-session.target graphical-session-pre.target

After creating these files:

systemctl --user daemon-reload

Session Desktop Entry

Ensure /usr/share/wayland-sessions/niri.desktop exists:

[Desktop Entry]
Name=Niri
Comment=A scrollable-tiling Wayland compositor
Exec=niri-session
Type=Application
DesktopNames=niri

Portal Configuration

Create ~/.config/xdg-desktop-portal/niri-portals.conf:

[preferred]
default=gtk
org.freedesktop.impl.portal.ScreenCast=gnome
org.freedesktop.impl.portal.Screenshot=gnome

Starting Niri

Important: Do NOT run niri directly. Use one of these methods:

  1. Via GDM (recommended): Log out, select "Niri" from the session menu (gear icon) at the login screen
  2. Via TTY: Run niri-session (not just niri)

Running bare niri skips session setup and breaks portal functionality.

NVIDIA Configuration

If using NVIDIA GPU, add to ~/.config/niri/config.kdl:

debug {
    render-drm-device "/dev/dri/renderD128"
}

Adjust the device path based on your system (ls /dev/dri/render*).

Screen Recording (OBS)

Known Issues

Screen recording with OBS + PipeWire + NVIDIA on Wayland has known issues:

  • "buffer is corrupt" errors
  • Black screen captures
  • Format negotiation failures

Current Status (Feb 2026)

The xdg-desktop-portal-gnome + niri + NVIDIA combination has compatibility issues. The portal may show windows but capture corrupt/blank frames.

Alternatives

  1. wlrobs plugin - Uses wlr-screencopy protocol directly (build from source)
  2. GPU-specific workarounds - Ensure niri and OBS use the same GPU
  3. Wait for fixes - OBS and portal implementations are actively being improved

PWA Font Scaling (Chrome/Brave)

Chrome/Brave PWAs ignore GTK font settings. Add --force-device-scale-factor=1.5 to desktop files.

Chrome PWAs

Edit files in ~/.local/share/applications/chrome-*.desktop:

Exec=/opt/google/chrome/google-chrome --force-device-scale-factor=1.5 ...

Brave PWAs

Brave on Ubuntu doesn't read brave-flags.conf. Create a wrapper script:

~/.local/bin/brave:

#!/bin/bash
FLAGS=""
if [[ -f ~/.config/brave-flags.conf ]]; then
    while read -r line; do
        [[ "$line" =~ ^#.*$ || -z "$line" ]] && continue
        FLAGS="$FLAGS $line"
    done < ~/.config/brave-flags.conf
fi
exec /opt/brave.com/brave/brave $FLAGS "$@"
chmod +x ~/.local/bin/brave

Then update Brave desktop files to use /home/$USER/.local/bin/brave instead of /opt/brave.com/brave/brave-browser.

~/.config/brave-flags.conf:

--force-device-scale-factor=1.5

Troubleshooting

Check niri is running as session

systemctl --user status niri.service

Check portal status

systemctl --user status xdg-desktop-portal xdg-desktop-portal-gnome
busctl --user introspect org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop | grep ScreenCast

View niri logs

journalctl --user -u niri.service -b

Check active screencasts

niri msg casts

Restart portals

systemctl --user restart xdg-desktop-portal

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment