commit:     460a8f68d767b8a634aed94cd7478e384b456f1c
Author:     Alexis <flexibeast <AT> gmail <DOT> com>
AuthorDate: Fri May  5 08:03:57 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May  5 08:35:36 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=460a8f68

media-video/pipewire: gentoo-pipewire-launcher.in: Add restart functionality.

Closes: https://bugs.gentoo.org/904851
Signed-off-by: Alexis <flexibeast <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../pipewire/files/gentoo-pipewire-launcher.in-r1  | 52 ++++++++++++++++++++++
 ...ewire-9999.ebuild => pipewire-0.3.70-r1.ebuild} |  2 +-
 media-video/pipewire/pipewire-9999.ebuild          |  2 +-
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/media-video/pipewire/files/gentoo-pipewire-launcher.in-r1 
b/media-video/pipewire/files/gentoo-pipewire-launcher.in-r1
new file mode 100644
index 000000000000..345298c0b6ae
--- /dev/null
+++ b/media-video/pipewire/files/gentoo-pipewire-launcher.in-r1
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# PipeWire launcher script for XDG compliant desktops on OpenRC.
+#
+# systemd users are very _STRONGLY_ advised to use the much
+# more reliable and predictable user units instead.
+
+# WARNING: This script assumes being run inside XDG compliant session,
+# which means D-Bus session instance is expected to be correctly set up
+# prior to this script starting. If that is not true, things may break!
+
+restart () {
+    echo "Terminating PipeWire processes ..."
+    pkill -u "${USER}" -x pipewire\|wireplumber 1>/dev/null 2>&1
+    pwait -u "${USER}" -x pipewire\|wireplumber
+    echo "PipeWire terminated."
+}
+
+if [ "${#}" -gt 0 ]
+then
+    if [ "${1}" = 'restart' ]
+    then
+       restart
+    else
+        echo "Unrecognised argument."
+       echo "Usage: gentoo-pipewire-launcher [restart]"
+       exit 1
+    fi
+fi
+
+if pgrep -u "${USER}" -x pipewire\|wireplumber 1>/dev/null 2>&1
+then
+    echo "PipeWire already running, exiting."
+    echo "(Use 'gentoo-pipewire-launcher restart' to restart PipeWire and 
WirePlumber.)"
+    exit 1
+fi
+
+# The core daemon which by itself does probably nothing.
+@GENTOO_PORTAGE_EPREFIX@/usr/bin/pipewire &
+
+# The so called pipewire-pulse daemon used for PulseAudio compatibility.
+# Commenting this out will stop the PA proxying daemon from starting,
+# however ALSA (with pipewire-alsa), JACK (with jack-sdk) and PW API using
+# clients will still have access to audio and may end up clashing with
+# non-PW apps over HW control (most notably, /usr/bin/pulseaudio daemon).
+@GENTOO_PORTAGE_EPREFIX@/usr/bin/pipewire -c pipewire-pulse.conf &
+
+# Hack for bug #822498
+sleep 1
+
+# Finally a session manager is required for PipeWire to do anything.
+exec @GENTOO_PORTAGE_EPREFIX@/usr/bin/wireplumber

diff --git a/media-video/pipewire/pipewire-9999.ebuild 
b/media-video/pipewire/pipewire-0.3.70-r1.ebuild
similarity index 99%
copy from media-video/pipewire/pipewire-9999.ebuild
copy to media-video/pipewire/pipewire-0.3.70-r1.ebuild
index a54b5c2d65dd..bfad8bec183e 100644
--- a/media-video/pipewire/pipewire-9999.ebuild
+++ b/media-video/pipewire/pipewire-0.3.70-r1.ebuild
@@ -310,7 +310,7 @@ multilib_src_install_all() {
                newins "${FILESDIR}"/pipewire.desktop-r1 pipewire.desktop
 
                exeinto /usr/bin
-               newexe "${FILESDIR}"/gentoo-pipewire-launcher.in 
gentoo-pipewire-launcher
+               newexe "${FILESDIR}"/gentoo-pipewire-launcher.in-r1 
gentoo-pipewire-launcher
 
                # Disable pipewire-pulse if sound-server is disabled.
                if ! use sound-server ; then

diff --git a/media-video/pipewire/pipewire-9999.ebuild 
b/media-video/pipewire/pipewire-9999.ebuild
index a54b5c2d65dd..bfad8bec183e 100644
--- a/media-video/pipewire/pipewire-9999.ebuild
+++ b/media-video/pipewire/pipewire-9999.ebuild
@@ -310,7 +310,7 @@ multilib_src_install_all() {
                newins "${FILESDIR}"/pipewire.desktop-r1 pipewire.desktop
 
                exeinto /usr/bin
-               newexe "${FILESDIR}"/gentoo-pipewire-launcher.in 
gentoo-pipewire-launcher
+               newexe "${FILESDIR}"/gentoo-pipewire-launcher.in-r1 
gentoo-pipewire-launcher
 
                # Disable pipewire-pulse if sound-server is disabled.
                if ! use sound-server ; then

Reply via email to