From 58ef45c013f11a60b0b088664997d4b62a6d0b64 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Mon, 26 Sep 2022 11:25:28 +0200 Subject: [PATCH] env: set $DISPLAY to use X server in WSL --- home/.zshenv | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/home/.zshenv b/home/.zshenv index 008acc8..1804103 100644 --- a/home/.zshenv +++ b/home/.zshenv @@ -48,3 +48,12 @@ export ZDOTDIR="$XDG_CONFIG_HOME/zsh" # [ "$(uname -s)" = "Darwin" ] || source "$XDG_CONFIG_HOME/shell/path.sh" +# Set $DISPLAY if running in WSL +# +# How to configure Windows Firewall for Xserver: https://skeptric.com/wsl2-xserver/ +# How to check if running in WSL: https://stackoverflow.com/a/61014411 +if [ $(uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip') ]; then + export DISPLAY=$(awk '/nameserver/ {print $2; exit}' /etc/resolv.conf 2>/dev/null):0.0 + export LIBGL_ALWAYS_INDIRECT=1 +fi +