Code

- Fix bug #390024: "raster image extensions fail on osx: missing ImageMagick
[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         # FIXME: Insecure tmp file usage.  Why do we have to copy this to /tmp anyway?
28         cp -f "$CWD/bin/getdisplay.sh" /tmp/
29         rm -f /tmp/display.$UID
30         open-x11 /tmp/getdisplay.sh || \
31         open -a XDarwin /tmp/getdisplay.sh || \
32         echo ":0" > /tmp/display.$UID
34         while [ "$?" == "0" -a ! -f /tmp/display.$UID ]; do
35             sleep 1
36         done
37         export DISPLAY=`cat /tmp/display.$UID`
39         ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11
40 fi
41         
42 # Warn the user about time-consuming generation of fontconfig caches.
43 test -f "${HOME}/.inkscape/.fccache-new" || exit 12
47 BASE=`echo "$0" | sed -e 's/\/Contents\/Resources\/script/\//'`
48 cd "$BASE"
49 exec "$CWD/bin/inkscape" "$@"
50 # TODO examine whether it would be wisest to move the code from inkscape shell
51 # script and getdisplay.sh to here and only keep the real binary in bin. This
52 # may make things easier on Leopard and may also help using Inkscape on the
53 # command line.