Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [Solved] Pipewire Service Scripts (Read 1729 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[Solved] Pipewire Service Scripts

Problem: cannot launch pipewire/-pulse/wireplumber as s6 user services.

Background:
I have set up user services with s6 as part of the main supervision tree. I used the usertree-maker command to enable the scan directory and then implemented the local-rc-user as in the wiki. This setup seems to work well. I wrote service scripts for pipewire, pipewire-pulse, and wireplumber that are launched by the local-rc-user. Unfortunately, these do not launch successfully. Pipewire and pipewire-pulse appear active within htop, but not wireplumber.

The pipewire log reads similar to this thread, which gives rtkit permission errors (can post on request). My user is added to the realtime group. Currently using a default configuration (e.g. kernel).

E: Dependencies are set up within the services: pulse depends on pipewire and wireplumber depends on both.

Current workaround:
I use a shell script to launch these in sequence (similar to the wiki). This works fine, which is why I think my fault may be in how I define my service run files.

Alternatively, I can launch pipewire and pipewire-pulse as services via the local-rc-user then launch wireplumber via script or command and that also seems to work fine.

Service run files:
Pipewire
Code: [Select]
#!/bin/execlineb -P
fdmove -c 2 1
importas -i XDG_RUNTIME_DIR XDG_RUNTIME_DIR
pipewire

Pipewire-pulse
Code: [Select]
#!/bin/execlineb -P
importas -i XDG_RUNTIME_DIR XDG_RUNTIME_DIR
pipewire-pulse

Wireplumber
Code: [Select]
#!/bin/execlineb -P
exec wireplumber

Does anybody have a recommendation on improving these so that they may execute properly?
I would like to have these supervised and managed by s6 instead of launching via a script.

Re: [H] Pipewire Service Scripts

Reply #1
Hello, I have configured in my way of course and it works. Everything can be improve of course:

In pipewire, I copied the file "/usr/share/pipewire/pipewire.conf" to "/etc/pipewire/pipewire.conf" and I made those changes, the key is "context.exec", with this configuration I'm telling Pipewire to execute "Wireplumber" and "Pipewire-pulse",I also have a "wireplumber.conf" because I'm using Sway with "seatd" and I'm not using "elogind" but if you use "elogind" you might not need the "wireplumber.conf" file and you can just run "wireplumber" without arguments.  I also copied the file "/usr/share/pipewire/pipewire-pulse.conf" to "/etc/pipewire/pipewire-pulse" and I made my own configurations to pipewire-pulse, I don't know if you use pipeware as pulseaudio drop-in but you might need it.

Code: [Select]
context.exec = [
    #{ path = <program-name> [ args = "<arguments>" ] }
    #
    # Execute the given program with arguments.
    #
    # You can optionally start the session manager here,
    # but it is better to start it as a systemd service.
    # Run the session manager with -h for options.
    #
    #{ path = "/usr/bin/pipewire-media-session"  args = "" }
    #{ path = "/usr/bin/pipewire-media-session"  args = "" }
    { path = "/usr/bin/wireplumber"  args = "-c wireplumber.conf" }
    #
    # You can optionally start the pulseaudio-server here as well
    # but it is better to start it as a systemd service.
    # It can be interesting to start another daemon here that listens
    # on another address with the -a option (eg. -a tcp:4713).
    #
    #{ path = "/usr/bin/pipewire" args = "-c pipewire-pulse.conf" }
    { path = "/usr/bin/pipewire" args = "-c pipewire-pulse.conf" }
]

These are my s6 custom scripts:

In the pipeware folder:

run
-------------------------------------
Code: [Select]
#!/usr/bin/execlineb -P
exec dbus-run-session pipewire
---------------------------------------

finish
-------------------------------------
Code: [Select]
#!/usr/bin/execlineb -P
exec pkill pipewire
---------------------------------------

type
-------------------------------------
Code: [Select]
longrun
---------------------------------------


Artix Linux Colombia

Re: [H] Pipewire Service Scripts

Reply #2
Thank you, I managed to get pipewire working (as a pulseaudio replacement) with your help.

For future readers, you can configure it as jrballesteros05 by running pipewire-pulse and wireplumber via pipewire. Alternatively, if you have it configured as in my initial post, you need to create a dbus user service. Consider this run file,

Code: [Select]
#!/bin/execlineb -P
fdmove -c 2 1
s6-envdir env
redirfd -w 4 env/DBUS_SESSION_BUS_ADDRESS
exec -c dbus-daemon --session --nofork --nopidfile --nosyslog --print-address=4

Then add the address to your other user service run files,

Code: [Select]
s6-envdir ../dbus-user-srv/env

Currently, Pipewire still does not acknowledge the realtime group (mod.rt errors are still logged), but everything works.