Skip to content

Commit

Permalink
[common] Check for existence only
Browse files Browse the repository at this point in the history
  • Loading branch information
goldyfruit committed Nov 21, 2023
1 parent 8e382c6 commit c821e61
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ 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
if [ -f "/run/user/${RUN_AS_UID}/pulse/native" ]; then
# Detect if a PulseAudio socket exists either Linux or WSL2
if [ -e "/run/user/${RUN_AS_UID}/pulse/native" ]; then
# When running on Linux
export PULSE_SERVER="/run/user/${RUN_AS_UID}/pulse/native"
elif [ -e "$PULSE_SOCKET_WSL2" ]; then
# When running on WSL2
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
Expand Down

0 comments on commit c821e61

Please sign in to comment.