<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Komeil's Personal website - voidlinux</title><link href="https://www.mmdbalkhi.ir/" rel="alternate"></link><link href="https://www.mmdbalkhi.ir/feeds/tags/voidlinux.atom.xml" rel="self"></link><id>https://www.mmdbalkhi.ir/</id><updated>2026-03-30T03:59:53+04:30</updated><entry><title>Runit user-side services</title><link href="https://www.mmdbalkhi.ir/blog/2026/Mar/30/runit-user-side-services/" rel="alternate"></link><published>2026-03-30T03:59:53+04:30</published><updated>2026-03-30T03:59:53+04:30</updated><author><name>Komeil</name></author><id>tag:www.mmdbalkhi.ir,2026-03-30:/blog/2026/Mar/30/runit-user-side-services/</id><summary type="html">&lt;p&gt;A minimal guide for runnit user-level services with runit&lt;/p&gt;</summary><content type="html">&lt;p&gt;A minimal guide for running &lt;strong&gt;user‑level services with runit&lt;/strong&gt; without systemd.&lt;/p&gt;
&lt;p&gt;This setup allows you to supervise background services in your user session (similar to &lt;code&gt;systemd --user&lt;/code&gt; units) using a lightweight runit service tree.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;runit can supervise services from any directory.
For user services we create a dedicated service directory and run a user instance of &lt;code&gt;runsvdir&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Example layout:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;~/.local/service/
&lt;span class="w"&gt;    &lt;/span&gt;pipewire/
&lt;span class="w"&gt;        &lt;/span&gt;run
&lt;span class="w"&gt;    &lt;/span&gt;wireplumber/
&lt;span class="w"&gt;        &lt;/span&gt;run
&lt;span class="w"&gt;    &lt;/span&gt;dunst/
&lt;span class="w"&gt;        &lt;/span&gt;run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Each directory represents one service.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;Starting the Supervisor&lt;/h2&gt;
&lt;p&gt;Run a user service tree with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;runsvdir&lt;span class="w"&gt; &lt;/span&gt;-P&lt;span class="w"&gt; &lt;/span&gt;~/.local/service
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This should be started &lt;strong&gt;inside your graphical/session environment&lt;/strong&gt; so services inherit variables like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;DBUS_SESSION_BUS_ADDRESS&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;WAYLAND_DISPLAY&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;XDG_RUNTIME_DIR&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Example (&lt;strong&gt;&lt;strong&gt;niri&lt;/strong&gt;&lt;/strong&gt; config):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;spawn runsvdir ~/.local/service
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;hr&gt;
&lt;h2&gt;Creating a Service&lt;/h2&gt;
&lt;p&gt;A runit service only needs a &lt;code&gt;run&lt;/code&gt; script.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;%&lt;span class="w"&gt; &lt;/span&gt;kak&lt;span class="w"&gt; &lt;/span&gt;~/.local/service/dunst/run&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;# Or easily you can use `./csrv dunst` for creating this staff&lt;/span&gt;
&lt;span class="c1"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;dunst
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;always use &lt;code&gt;exec&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;do not daemonize programs&lt;/li&gt;
&lt;li&gt;do not use &lt;code&gt;&amp;amp;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Make it executable:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;chmod&lt;span class="w"&gt; &lt;/span&gt;+x&lt;span class="w"&gt; &lt;/span&gt;run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The service will start automatically when &lt;code&gt;runsvdir&lt;/code&gt; sees it.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;Managing Services&lt;/h2&gt;
&lt;p&gt;Use &lt;code&gt;sv&lt;/code&gt; to control services.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sv&lt;span class="w"&gt; &lt;/span&gt;status&lt;span class="w"&gt; &lt;/span&gt;~/.local/service/*
sv&lt;span class="w"&gt; &lt;/span&gt;restart&lt;span class="w"&gt; &lt;/span&gt;~/.local/service/dunst&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;# Yeah, we also have ./sv-user script for this&lt;/span&gt;
sv&lt;span class="w"&gt; &lt;/span&gt;down&lt;span class="w"&gt; &lt;/span&gt;~/.local/service/dunst
sv&lt;span class="w"&gt; &lt;/span&gt;up&lt;span class="w"&gt; &lt;/span&gt;~/.local/service/dunst
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;hr&gt;
&lt;h2&gt;Logging (optional)&lt;/h2&gt;
&lt;p&gt;Add a logging service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;service/foo/log/run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;svlogd&lt;span class="w"&gt; &lt;/span&gt;-tt&lt;span class="w"&gt; &lt;/span&gt;./main
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Logs will appear in:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;service/foo/log/main/current
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;hr&gt;
&lt;h2&gt;One‑Shot Services&lt;/h2&gt;
&lt;p&gt;For tasks that should &lt;strong&gt;not automatically restart&lt;/strong&gt;, create a &lt;code&gt;down&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;touch service/wallpaper/down
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Run manually:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sv up service/wallpaper
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;hr&gt;
&lt;h2&gt;Tips&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Keep &lt;code&gt;run&lt;/code&gt; scripts simple.&lt;/li&gt;
&lt;li&gt;Avoid running multiple instances of the same program.&lt;/li&gt;
&lt;li&gt;Separate &lt;strong&gt;core services&lt;/strong&gt; (pipewire, portals) from &lt;strong&gt;session services&lt;/strong&gt; (notifications, idle managers).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;See Also:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;A few user-side services &lt;a href="https://cgit.mmdbalkhi.ir/runit-user.git/"&gt;git&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><category term="blog"></category><category term="runit"></category><category term="desystemd"></category><category term="voidlinux"></category></entry></feed>