Added old-school WSL Xauthority configuration

This commit is contained in:
siriusfox 2023-11-24 12:08:37 -08:00
parent 56a38c8e51
commit 1871c5dde6

View file

@ -0,0 +1,14 @@
#!/bin/bash
# Provides a stub for WSL when using X11 forwarding to ensure the xauthority is updated correctly.
# First make a timestamp that represents "startup" timestamp
touch "$HOME/.uptime_tag" -d "$(uptime -s)"
# If file is missing or is outdated, fix it!
if [[ ! -e "$HOME/.Xauthority" || "$HOME/.uptime_tag" -nt "$HOME/.Xauthority" ]]; then
# then create the new Xauthority file IF display is defined
# but only do it if we have a display
if [[ ! -z "$DISPLAY" ]]; then
xauth add "$DISPLAY" . $(mcookie)
fi
fi