From 2d1af667b96d9f8d80a4aec217d8a1f48a946bb2 Mon Sep 17 00:00:00 2001
From: zachir <zachir@librem.one>
Date: Thu, 6 Jun 2024 15:25:36 -0500
Subject: Add runit user services as well

---
 runit/sv/pipewire-pulse/conf    | 12 ++++++++++++
 runit/sv/pipewire-pulse/log/run | 12 ++++++++++++
 runit/sv/pipewire-pulse/run     | 12 ++++++++++++
 3 files changed, 36 insertions(+)
 create mode 100644 runit/sv/pipewire-pulse/conf
 create mode 100755 runit/sv/pipewire-pulse/log/run
 create mode 100755 runit/sv/pipewire-pulse/run

(limited to 'runit/sv/pipewire-pulse')

diff --git a/runit/sv/pipewire-pulse/conf b/runit/sv/pipewire-pulse/conf
new file mode 100644
index 0000000..606eac5
--- /dev/null
+++ b/runit/sv/pipewire-pulse/conf
@@ -0,0 +1,12 @@
+# -*- mode: sh; -*-
+
+# Additional command line arguments for pipewire-pulse.
+OPTS=''
+
+# Setting this to 1 enables logging, any other value - disables.
+LOGGING_ENABLE=0
+# Set the pipewire log level.
+# See: https://docs.pipewire.org/page_daemon.html#sec_logging
+LOG_LEVEL=1
+# The directory will be created for you, if logging is enabled.
+LOG_DIR="$HOME/.local/var/log/pipewire-pulse"
diff --git a/runit/sv/pipewire-pulse/log/run b/runit/sv/pipewire-pulse/log/run
new file mode 100755
index 0000000..ba8236e
--- /dev/null
+++ b/runit/sv/pipewire-pulse/log/run
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+[ -r ../conf ] && . ../conf
+
+if [ "${LOGGING_ENABLE}x" = "1x" ]; then
+    # Create the log directory if not exists.
+    [ -d "${LOG_DIR}" ] || mkdir -p "${LOG_DIR}"
+
+    exec svlogd -tt "${LOG_DIR}"
+else
+    exec chpst -b pipewire-pulse-log-null cat >/dev/null
+fi
diff --git a/runit/sv/pipewire-pulse/run b/runit/sv/pipewire-pulse/run
new file mode 100755
index 0000000..0e43d6f
--- /dev/null
+++ b/runit/sv/pipewire-pulse/run
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Wait for the PipeWire Media Session daemon to start.
+sv check "$HOME/.config/runit/sv/wireplumber" >/dev/null || exit 1
+
+[ -r ./conf ] && . ./conf
+
+if [ "${LOGGING_ENABLE}x" = "1x" -a -n "${LOG_LEVEL}" ]; then
+    export PIPEWIRE_DEBUG="${LOG_LEVEL}"
+fi
+
+exec pipewire-pulse ${OPTS:-} 2>&1
-- 
cgit v1.2.3