From 91c239ee58ff36dfe235a13b7286fd36bd5a08f8 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Tue, 19 Oct 2021 10:15:38 +0100 Subject: [PATCH 1/3] Add install files to the build --- Makefile.am | 2 +- configure.ac | 3 ++- instfiles/Makefile.am | 33 ++++++++++++++++++++++++++++ instfiles/load_pa_modules.sh | 32 +++++++++++++++++++++++++++ instfiles/pulseaudio-xrdp.desktop.in | 9 ++++++++ 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 instfiles/Makefile.am create mode 100755 instfiles/load_pa_modules.sh create mode 100644 instfiles/pulseaudio-xrdp.desktop.in diff --git a/Makefile.am b/Makefile.am index 3bc4e60..e944705 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = src +SUBDIRS = src instfiles EXTRA_DIST = bootstrap.sh diff --git a/configure.ac b/configure.ac index 4d30e39..d4090b4 100644 --- a/configure.ac +++ b/configure.ac @@ -80,5 +80,6 @@ AC_TYPE_UINT32_T AC_CHECK_FUNCS([memset socket]) AC_CONFIG_FILES([Makefile - src/Makefile]) + src/Makefile + instfiles/Makefile]) AC_OUTPUT diff --git a/instfiles/Makefile.am b/instfiles/Makefile.am new file mode 100644 index 0000000..9c281fe --- /dev/null +++ b/instfiles/Makefile.am @@ -0,0 +1,33 @@ +EXTRA_DIST = \ + load_pa_modules.sh \ + pulseaudio-xrdp.desktop.in + +# +# substitute directories in service file +# +CLEANFILES= \ + pulseaudio-xrdp.desktop + +SUBST_VARS = sed \ + -e 's|@pkglibexecdir[@]|$(pkglibexecdir)|g' + +subst_verbose = $(subst_verbose_@AM_V@) +subst_verbose_ = $(subst_verbose_@AM_DEFAULT_V@) +subst_verbose_0 = @echo " SUBST $@"; + +SUFFIXES = .in +.in: + $(subst_verbose)$(SUBST_VARS) $< > $@ + +# +# files for all platforms +# + +# Don't use sysconfdir for this one as it won't work! +xdgautostartdir=/etc/xdg/autostart + +xdgautostart_DATA = \ + pulseaudio-xrdp.desktop + +pkglibexec_SCRIPTS = \ + load_pa_modules.sh diff --git a/instfiles/load_pa_modules.sh b/instfiles/load_pa_modules.sh new file mode 100755 index 0000000..bfb2bc6 --- /dev/null +++ b/instfiles/load_pa_modules.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +PACTL=/usr/bin/pactl + +if [ -n "$XRDP_SESSION" -a -n "$XRDP_SOCKET_PATH" ]; then + # These values are not present on xrdp versions before v0.9.8 + if [ -z "$XRDP_PULSE_SINK_SOCKET" -o \ + -z "$XRDP_PULSE_SOURCE_SOCKET" ]; then + displaynum=${DISPLAY##*:} + displaynum=${displaynum%.*} + XRDP_PULSE_SINK_SOCKET=xrdp_chansrv_audio_out_socket_$displaynum + XRDP_PULSE_SOURCE_SOCKET=xrdp_chansrv_audio_in_socket_$displaynum + fi + + # Don't check for the presence of the sockets, as if the modules + # are loaded they won't be there + + # Unload modules + $PACTL unload-module module-xrdp-sink >/dev/null 2>&1 + $PACTL unload-module module-xrdp-source >/dev/null 2>&1 + + # Reload modules + $PACTL load-module module-xrdp-sink \ + xrdp_socket_path=$XRDP_SOCKET_PATH \ + xrdp_pulse_sink_socket=$XRDP_PULSE_SINK_SOCKET && \ + \ + $PACTL load-module module-xrdp-source \ + xrdp_socket_path=$XRDP_SOCKET_PATH \ + xrdp_pulse_source_socket=$XRDP_PULSE_SOURCE_SOCKET +fi + +exit $? diff --git a/instfiles/pulseaudio-xrdp.desktop.in b/instfiles/pulseaudio-xrdp.desktop.in new file mode 100644 index 0000000..baac740 --- /dev/null +++ b/instfiles/pulseaudio-xrdp.desktop.in @@ -0,0 +1,9 @@ +[Desktop Entry] +Version=1.0 +Name=PulseAudio xrdp modules +Comment=Load PulseAudio Modules for xrdp +Exec=@pkglibexecdir@/load_pa_modules.sh +Terminal=false +Type=Application +Categories= +GenericName= From d37b40dc073d6f9a884f2317fc48bc83a98ff921 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Thu, 4 Nov 2021 13:55:53 +0000 Subject: [PATCH 2/3] Make xdgautostartdir configurable --- configure.ac | 10 ++++++++++ instfiles/Makefile.am | 4 ---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index d4090b4..f4bf72d 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,9 @@ PA_LIBDIR=`$PKG_CONFIG --variable=libdir libpulse` PA_MODDIR=`$PKG_CONFIG --variable=modlibexecdir libpulse` PA_PREFIX=`$PKG_CONFIG --variable=prefix libpulse` +# Default system-wide autostart directory from XDG autostart specification +m4_define([XDG_AUTOSTART_DIR], /etc/xdg/autostart) + AC_SUBST([PA_MAJOR], [pa_major]) AC_SUBST([PA_MINOR], [pa_minor]) AC_SUBST([PA_MAJORMINOR], [pa_major].[pa_minor]) @@ -68,6 +71,13 @@ AC_ARG_WITH( [modlibexecdir=$withval], [modlibexecdir="${PA_MODDIR}"]) AC_SUBST(modlibexecdir) +AC_ARG_WITH( + [xdgautostart-dir], + [AS_HELP_STRING([--with-xdgautostart-dir], + Directory to install the desktop file (defaults to XDG_AUTOSTART_DIR))], + [xdgautostartdir=$withval], [xdgautostartdir=XDG_AUTOSTART_DIR]) +AC_SUBST(xdgautostartdir) + # Checks for header files. AC_CHECK_HEADERS([fcntl.h limits.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h]) diff --git a/instfiles/Makefile.am b/instfiles/Makefile.am index 9c281fe..59a1508 100644 --- a/instfiles/Makefile.am +++ b/instfiles/Makefile.am @@ -22,10 +22,6 @@ SUFFIXES = .in # # files for all platforms # - -# Don't use sysconfdir for this one as it won't work! -xdgautostartdir=/etc/xdg/autostart - xdgautostart_DATA = \ pulseaudio-xrdp.desktop From 2a326d7411cc4b4dd955b985151cd6d2c4fdaa7b Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Tue, 9 Nov 2021 08:58:08 +0000 Subject: [PATCH 3/3] Changes following review and retest - Find pactl in PATH - Set default source/sink for xrdp sessions - Exit status returned from instfiles/load_pa_modules.sh --- instfiles/load_pa_modules.sh | 44 +++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/instfiles/load_pa_modules.sh b/instfiles/load_pa_modules.sh index bfb2bc6..350f8e9 100755 --- a/instfiles/load_pa_modules.sh +++ b/instfiles/load_pa_modules.sh @@ -1,6 +1,6 @@ #!/bin/sh -PACTL=/usr/bin/pactl +status=0 if [ -n "$XRDP_SESSION" -a -n "$XRDP_SOCKET_PATH" ]; then # These values are not present on xrdp versions before v0.9.8 @@ -16,17 +16,39 @@ if [ -n "$XRDP_SESSION" -a -n "$XRDP_SOCKET_PATH" ]; then # are loaded they won't be there # Unload modules - $PACTL unload-module module-xrdp-sink >/dev/null 2>&1 - $PACTL unload-module module-xrdp-source >/dev/null 2>&1 + pactl unload-module module-xrdp-sink >/dev/null 2>&1 + pactl unload-module module-xrdp-source >/dev/null 2>&1 # Reload modules - $PACTL load-module module-xrdp-sink \ - xrdp_socket_path=$XRDP_SOCKET_PATH \ - xrdp_pulse_sink_socket=$XRDP_PULSE_SINK_SOCKET && \ - \ - $PACTL load-module module-xrdp-source \ - xrdp_socket_path=$XRDP_SOCKET_PATH \ - xrdp_pulse_source_socket=$XRDP_PULSE_SOURCE_SOCKET + if pactl load-module module-xrdp-sink \ + xrdp_socket_path=$XRDP_SOCKET_PATH \ + xrdp_pulse_sink_socket=$XRDP_PULSE_SINK_SOCKET + then + echo "- pulseaudio xrdp-sink loaded" + if pacmd set-default-sink xrdp-sink; then + echo "- pulseaudio xrdp-sink set as default" + else + echo "? Can't set pulseaudio xrdp-sink as default" + fi + else + echo "? Can't load pulseaudio xrdp-sink" + status=1 + fi + + if pactl load-module module-xrdp-source \ + xrdp_socket_path=$XRDP_SOCKET_PATH \ + xrdp_pulse_source_socket=$XRDP_PULSE_SOURCE_SOCKET + then + echo "- pulseaudio xrdp-source loaded" + if pacmd set-default-source xrdp-source; then + echo "- pulseaudio xrdp-source set as default" + else + echo "? Can't set pulseaudio xrdp-source as default" + fi + else + echo "? Can't load pulseaudio xrdp-source" + status=1 + fi fi -exit $? +exit $status