Table of contents
When starting niri from a display manager like GDM, or otherwise through the 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.
Here's an example on how you might set up mako, waybar, swaybg and swayidle to run as systemd services with niri.
Unlike spawn-at-startup, this lets you easily monitor their status and output, and restart or reload them.
-
Install them, i.e.
sudo dnf install mako waybar swaybg swayidle -
makoandwaybarprovide systemd units out of the box, so you can simply add them to the niri session:systemctl --user add-wants niri.service mako.service systemctl --user add-wants niri.service waybar.serviceThis will create links in
~/.config/systemd/user/niri.service.wants/, a special systemd folder for services that need to start together withniri.service. -
swaybgdoes 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~/.config/systemd/user/swaybg.servicewith the following contents:[Unit] PartOf=graphical-session.target After=graphical-session.target Requisite=graphical-session.target [Service] ExecStart=/usr/bin/swaybg -m fill -i "%h/Pictures/LakeSide.png" Restart=on-failureReplace the image path with the one you want.
%his expanded to your home directory.After editing
swaybg.service, runsystemctl --user daemon-reloadso systemd picks up the changes in the file.Now, add it to the niri session:
systemctl --user add-wants niri.service swaybg.service -
swayidlesimilarly does not provide a service, so we will also make our own. Create~/.config/systemd/user/swayidle.servicewith the following contents:[Unit] PartOf=graphical-session.target After=graphical-session.target Requisite=graphical-session.target [Service] ExecStart=/usr/bin/swayidle -w timeout 601 'niri msg action power-off-monitors' timeout 600 'swaylock -f' before-sleep 'swaylock -f' Restart=on-failureThen, run
systemctl --user daemon-reloadand add it to the niri session:systemctl --user add-wants niri.service swayidle.service
That's it!
Now these three utilities will be started together with the niri session and stopped when it exits.
You can also restart them with a command like systemctl --user restart waybar.service, for example after editing their config files.
To remove a service from niri startup, remove its symbolic link from ~/.config/systemd/user/niri.service.wants/.
Then, run systemctl --user daemon-reload.
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, like tmux, dtach or similar, to persist in this case. To do this, run it in a transient systemd scope:
systemd-run --user --scope tmux new-session
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Usage
- Getting Started
- Example systemd Setup
- Important Software
- Workspaces
- Floating Windows
- Tabs
- Overview
- Screencasting
- Layer‐Shell Components
- IPC,
niri msg - Application-Specific Issues
- Nvidia
- Xwayland
- Gestures
- Fullscreen and Maximize
- Window Effects
- Packaging niri
- Integrating niri
- Security Model
- Accessibility
- Name and Logo
- FAQ
Configuration
- Introduction
- Input
- Outputs
- Key Bindings
- Switch Events
- Layout
- Named Workspaces
- Miscellaneous
- Window Rules
- Layer Rules
- Animations
- Gestures
- Recent Windows
- Debug Options
- Include