Code

* packaging/macosx/ScriptExec/main.c: Update ScriptExec with upstream fixes
[inkscape.git] / packaging / macosx / Resources / script
1 #!/bin/sh
2 #
3 # Author: Aaron Voisine <aaron@voisine.org>
4 # Inkscape Modifications: Michael Wybrow <mjwybrow@users.sourceforge.net>
6 CWD="`dirname \"$0\"`"
8 # System version: 3 for Panther, 4 for Tiger, 5 for Leopard
9 export VERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d'.'`
11 # On Leopard, X11.app is installed by default, and will be started
12 # automatically via launchd.  On older systems, we need to start 
13 # X11 ourself.
15 # For Panther and Tiger, start X11
16 if [[ $VERSION -le 4 ]]; then
17         # FIXME apparently this removes the xterm that starts with X 
18         # from xinitrc but when is it really used? Should we modify 
19         # the .xinitrc of the user without warning?
20         ps -wx -ocommand | grep -e '[X]11' > /dev/null
21         if [ "$?" != "0" -a ! -f ${HOME}/.xinitrc ]; then
22             echo "rm -f ${HOME}/.xinitrc" > ${HOME}/.xinitrc
23             sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> ${HOME}/.xinitrc
24         fi
26         # Start X11 and get DISPLAY
27         cp -f "$CWD/bin/getdisplay.sh" /tmp/
28         rm -f /tmp/display.$UID
29         open-x11 /tmp/getdisplay.sh || \
30         open -a XDarwin /tmp/getdisplay.sh || \
31         echo ":0" > /tmp/display.$UID
33         while [ "$?" == "0" -a ! -f /tmp/display.$UID ]; do
34             sleep 1
35         done
36         export DISPLAY="`cat /tmp/display.$UID`"
38         ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11
39 fi
42 # Warn the user about time-consuming generation of fontconfig caches.
43 test -d ${HOME}/.fontconfig || exit 12
46 BASE="`echo "$0" | sed -e 's/\/Contents\/Resources\/script/\//'`"
47 cd "$BASE"
48 exec "$CWD/bin/inkscape" "$@"
49 # TODO examine wether it would be wisest to move the code from inkscape shell
50 # script and getdisplay.sh to here and only keep the real binary in bin. This
51 # may make things easier on Leopard and may also help using Inkscape on the
52 # command line