Continuing this tutorial series on service files, today we’ll look at a simple, comparable way to make “user services” available in Nitrux. OpenRC did not have a concept of “user services” as defined by systemd: “[…] manage services under the user’s control with a per-user systemd instance, enabling users to start, stop, enable, and disable their own units.”

However, while OpenRC now supports user services starting with version 0.60, we’ll create the equivalent in a much simpler, and importantly, rootless way.

Difficulty: ★☆☆☆☆


Services as a User

Most users are familiar with the system-wide services managed by the init-system; think of your packaged Docker daemon or the NetworkManager daemon. These services exist in /etc/init.d and run with root privileges, and have one thing in common: once enabled, they start and stop with system boot and shutdown, depending on their runlevel.

But a “service” can be created and entirely controlled by regular unprivileged (i.e., non-root) users. Usually, to achieve this functionality, we’d use a standard XDG path ($XDG_CONFIG_HOME/autostart); however, since Nitrux 5.0.0, we’ve been using Hyprland, which works differently in this regard.

Instead of adding a desktop launcher to the XDG directory as we’d do for other sessions, like KDE Plasma, we only add the executable we want to autostart to the configuration file in: ~/.config/hypr/hyprland.lua, like this:

-------------------
---- AUTOSTART ----
-------------------

hl.on("hyprland.start", function()
    hl.exec_cmd("waybar")
end)

Once we log out and log in, the executable will run when the session starts, therefore fulfilling the definition of “managing services under the user’s control; enabling users to start, stop, enable, and disable their own”. Each of these background executables will start and stop with the user session.


That’s it; this concludes today’s tutorial and this series about user services in Nitrux.