From 809dc3b96b6fbe6f6f895f55b41deb6a6a87872a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Trellu?= Date: Tue, 21 Nov 2023 09:44:46 -0500 Subject: [PATCH] [common] Use the correct PULSE_SERVER socket --- utils/common.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/common.sh b/utils/common.sh index a0e54b1..ab47950 100644 --- a/utils/common.sh +++ b/utils/common.sh @@ -56,7 +56,11 @@ function detect_sound() { # Looking for any pulse processes if [[ "$(pgrep -a -f "pulse" | awk -F"/" '{ print $NF }' 2>>"$LOG_FILE")" =~ "pulse" ]]; then # PULSE_SERVER is required by pactl as it is executed via sudo - export PULSE_SERVER="/run/user/${RUN_AS_UID}/pulse/native" + if [ -f "/run/user/${RUN_AS_UID}/pulse/native" ]; then + export PULSE_SERVER="/run/user/${RUN_AS_UID}/pulse/native" + elif [ -f "$PULSE_SOCKET_WSL2" ]; then + export PULSE_SERVER="$PULSE_SOCKET_WSL2" + fi if command -v pactl &>>"$LOG_FILE"; then SOUND_SERVER="$(pactl info | awk -F":" '$1 ~ /Server Name/ { print $2 }' | sed 's/^ *//')" else