Skip to content

Instantly share code, notes, and snippets.

@rsletta
Created December 9, 2019 09:03
Show Gist options
  • Save rsletta/0b634d717dd812bfb841383ca91e4974 to your computer and use it in GitHub Desktop.
Save rsletta/0b634d717dd812bfb841383ca91e4974 to your computer and use it in GitHub Desktop.
wsl-integration.sh after edit
if type pactl > /dev/null 2>&1 || type xvinfo > /dev/null 2>&1; then
# detect WSL host
if type systemd-detect-virt > /dev/null 2>&1 && test "$(systemd-detect-virt -c)" != wsl -a -e /etc/resolv.conf; then
WSL_HOST=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null)
fi
WSL_HOST=${WSL_HOST:-localhost}
# set DISPLAY if there is an X11 server running
#if type xvinfo > /dev/null 2>&1 && env DISPLAY=${WSL_HOST}:0 xvinfo > /dev/null 2>&1; then
# export DISPLAY=${WSL_HOST}:0
# export LIBGL_ALWAYS_INDIRECT=1
#fi
# set up audio if pulse server is reachable only via tcp
#if type pactl > /dev/null 2>&1 \
# && (! pactl info > /dev/null 2>&1 || pactl info 2> /dev/null | grep -q 'Default Sink: auto_null' ) \
# && env PULSE_SERVER=tcp:${WSL_HOST} pactl info > /dev/null 2>&1; then
# export PULSE_SERVER=tcp:${WSL_HOST}
#fi
unset WSL_HOST
fi
@AhmedMustafa2201
Copy link

@rsletta great job. I've tried to do the same, but there's nothing on my /etc/profile.d/wsl-integration.sh file through my ubuntu wsl2. do you know the root cause for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment