cat << EOF | sudo tee /etc/gdm/PostLogin/Default #!/bin/bash auth=\$HOME/.Xauthority if [ -e \$auth ]; then diff <(xauth extract - \$DISPLAY) \\ <(XAUTHORITY=\$auth xauth extract - \$DISPLAY) > /dev/null \\ && exit 0 fi xauth extract - \$DISPLAY | XAUTHORITY=\$auth xauth merge - EOF sudo chmod +x /etc/gdm/PostLogin/Default