From e0d88a9ee1d85c43405f557ca469c42dfdcde597 Mon Sep 17 00:00:00 2001
From: Marty Oehme <contact@martyoeh.me>
Date: Tue, 25 Feb 2025 18:40:08 +0100
Subject: [PATCH] feat(system): Move user services to XDG_STATE_HOME directory

User services under control of runit under turnstiled now default to the
`~/.local/state/service/` directory (and `~/.local/state/service-env/`
for the env vars). This mimics the system-wide runit setup, with service
templates kept in `/etc/sv` (in my case `~/.config/sv` for user
services) and active ones in `/var/service`
---
 books/files/runit.conf  | 16 ++++++++++++++++
 books/void_wayland.yaml |  6 ++++++
 2 files changed, 22 insertions(+)
 create mode 100644 books/files/runit.conf

diff --git a/books/files/runit.conf b/books/files/runit.conf
new file mode 100644
index 0000000..0afe045
--- /dev/null
+++ b/books/files/runit.conf
@@ -0,0 +1,16 @@
+# This is the configuration file for turnstile's runit backend.
+#
+# It follows the POSIX shell syntax (being sourced into a script).
+# The complete launch environment available to dinit can be used.
+#
+# It is a low-level configuration file. In most cases, it should
+# not be modified by the user.
+
+# the name of the service that turnstile will check for login readiness
+ready_sv="turnstile-ready"
+
+# the directory user service files are read from.
+services_dir="${HOME}/.local/state/service"
+
+# the environment variable directory user service files can read from.
+service_env_dir="${HOME}/.local/state/service-env"
diff --git a/books/void_wayland.yaml b/books/void_wayland.yaml
index 7672138..4da6830 100644
--- a/books/void_wayland.yaml
+++ b/books/void_wayland.yaml
@@ -26,6 +26,12 @@
         state: link
       with_items: [dbus, turnstiled, seatd]
 
+    - name: Set user service directory to $HOME/.local/state/service
+      ansible.builtin.copy:
+        src: runit.conf
+        dest: /etc/turnstile/backend/runit.conf
+        mode: 0644
+
     - name: Install wlr desktop portals
       community.general.xbps:
         name: