niri-session binary, it runs as a systemd service. This provides the necessary systemd integration to run programs like mako and services like xdg-desktop-portal bound to the graphical session.
Unlike
spawn-at-startup, using systemd services lets you easily monitor their status and output, and restart or reload them.mako, waybar, swaybg, and swayidle to run as systemd services with niri.
Setting Up Components
Step 1: Install Components
First, install the components you want to use:Adjust the package manager command for your distribution (e.g.,
apt, pacman, zypper).Step 2: Components with Built-in Units
mako and waybar provide systemd units out of the box, so you can simply add them to the niri session:
This will create links in
~/.config/systemd/user/niri.service.wants/, a special systemd folder for services that need to start together with niri.service.Step 3: Create Custom Service for swaybg
swaybg does not provide a systemd unit, since you need to pass the background image as a command-line argument. So we will make our own.
Create the service file
Create
~/.config/systemd/user/swaybg.service with the following contents:Replace the image path with the one you want.
%h is expanded to your home directory.Reload systemd
After editing This ensures systemd picks up the changes in the file.
swaybg.service, run:Step 4: Create Custom Service for swayidle
swayidle similarly does not provide a service, so we will also make our own.
Managing Services
Restart a Service
You can restart services with a command like this (for example, after editing their config files):Check Service Status
View Service Logs
Remove a Service
To remove a service from niri startup:Running Programs Across Logout
When running niri as a session, exiting it (logging out) will kill all programs that you’ve started within. However, sometimes you want a program, liketmux, dtach or similar, to persist in this case.
This detaches the program from your session’s lifecycle, allowing it to continue running even after you log out.
systemd Unit Template Reference
Here’s a template you can use for creating your own systemd services:Replace
my-program --with-args with your actual command and arguments.