From 1871c5dde61dc90bec20e5d51e383981a78f2310 Mon Sep 17 00:00:00 2001 From: siriusfox Date: Fri, 24 Nov 2023 12:08:37 -0800 Subject: [PATCH] Added old-school WSL Xauthority configuration --- 2018-xx-xx_wsl-xauthority.bashrc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 2018-xx-xx_wsl-xauthority.bashrc diff --git a/2018-xx-xx_wsl-xauthority.bashrc b/2018-xx-xx_wsl-xauthority.bashrc new file mode 100644 index 0000000..f36779a --- /dev/null +++ b/2018-xx-xx_wsl-xauthority.bashrc @@ -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