Code

986cb530bd188d1884cd576f189ad23b3f4f123d
[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 VERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d'.'`
12 # FIXME apparently this removes the xterm that starts with X from xinitrc but when is it really used? Should we modify the .xinitrc of the user without warning?
13 ps -wx -ocommand | grep -e '[X]11' > /dev/null
14 if [ "$?" != "0" -a ! -f ~/.xinitrc ]; then
15     echo "rm -f ~/.xinitrc" > ~/.xinitrc
16     sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> ~/.xinitrc
17 fi
19 # For Panther and Tiger, start X11
20 if [[ $VERSION -le 4 ]]; then
21         # Start X11 and get DISPLAY
22         cp -f "$CWD/bin/getdisplay.sh" /tmp/
23         rm -f /tmp/display.$UID
24         open-x11 /tmp/getdisplay.sh || \
25         open -a XDarwin /tmp/getdisplay.sh || \
26         echo ":0" > /tmp/display.$UID
28         while [ "$?" == "0" -a ! -f /tmp/display.$UID ]; do
29             sleep 1
30         done
31         export DISPLAY="`cat /tmp/display.$UID`"
33         ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11
34 fi
36 # In Leopard, X11 should start on itself
39 # Warn the user about time-consuming generation of fontconfig caches.
40 test -f ~/.inkscape/.fccache-new || exit 12
43 BASE="`echo "$0" | sed -e 's/\/Contents\/Resources\/script/\//'`"
44 cd "$BASE"
45 exec "$CWD/bin/inkscape" "$@"
46 # TODO examine wether it would be wisest to move the code from inkscape shell script and getdisplay.sh to here and only keep the real binary in bin. This may make things easier on Leopard and may also help using Inkscape on the command line