Skip to content

Instantly share code, notes, and snippets.

@GongT
Created June 10, 2017 22:31
Show Gist options
  • Save GongT/82502b7bc8d8c4aaab91bdfa4927efef to your computer and use it in GitHub Desktop.
Save GongT/82502b7bc8d8c4aaab91bdfa4927efef to your computer and use it in GitHub Desktop.
start X.org on windows with cygwin.
#/bin/bash
# create a LNK file:
# C:\cygwin64\bin\mintty.exe -w hide -h error -e /bin/env /usr/local/bin/startx.sh
# ^ cygwin install path ^ this file path in cygwin root
set -x
set -e
export PATH="/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin"
LIST="$(screen -list 2>&1 || true)"
RET=$?
function alert {
[ ! -e /tmp/msgbox.js ] || echo "WScript.Echo(WScript.Arguments.Item(0));" > /tmp/msgbox.js
/cygdrive/c/WINDOWS/system32/wscript "$(cygpath --mixed /tmp/msgbox.js)" "$@"
}
if [ $RET -eq 0 ] ; then
if echo "$LIST" | grep -q 'xorg' ; then
if echo "$LIST" | grep 'xorg' | grep -q 'Dead' ; then
alert "process died..."
screen -wipe || true
else
alert "server already started."
exit 0
fi
fi
else # may be no screen, and may be error
if echo "$LIST" | grep -q 'No Sockets found in' ; then
echo "no screen. start new."
else
alert 'something worng...'
exit 1
fi
fi
cat << START_X > /tmp/start-xwin.sh
#!/bin/sh
X :${1-0} -ac +bs -wm -listen tcp -reset +xinerama -clipboard \
-compositealpha -compositewm -noemulate3buttons -keyhook -lesspointer \
-wgl -nounixkill -nowinkill -logverbose 0 -logfile xorg.log -silent-dup-error \
-multiwindow -primary -multimonitors # -screen 0 @1 -screen 1 @2
START_X
cd /home
rm -f xorg.log.old xorg.log
screen -L -dmS xorg sh "/tmp/start-xwin.sh"
screen -list
echo "debug: exit end."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment