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