Code

- Fix bug #390024: "raster image extensions fail on osx: missing ImageMagick
[inkscape.git] / packaging / macosx / Resources / bin / inkscape
1 #!/bin/sh
2 #
3 # Author: Aaron Voisine <aaron@voisine.org>
4 # Inkscape Modifications:
5 #       Michael Wybrow <mjwybrow@users.sourceforge.net>
6 #       Jean-Olivier Irisson <jo.irisson@gmail.com>
7 #
9 CWD="`(cd \"\`dirname \\\"$0\\\"\`\"; echo $PWD)`"
10 # e.g. /Applications/Inkscape.app/Contents/Resources/bin
11 TOP="`dirname \"$CWD\"`"
12 # e.g. /Applications/Inkscape.app/Contents/Resources
15 # Brutally add many things to the PATH. If the directories do not exist, they won't be used anyway. 
16 # People should really use ~/.macosx/environment.plist to set environment variables as explained by Apple:
17 #       http://developer.apple.com/qa/qa2001/qa1067.html
18 # but since no one does, we correct this by making the 'classic' PATH additions here:
19 #       /usr/local/bin which, though standard, doesn't seem to be in the PATH
20 #       newer python as recommended by MacPython http://www.python.org/download/mac/
21 #       Fink
22 #       MacPorts (former DarwinPorts)
23 #       LaTeX distribution for Mac OS X
24 export PATH="/usr/texbin:/opt/local/bin:/sw/bin/:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/bin:$CWD:$PATH"
26 # Setup PYTHONPATH to use python modules shipped with Inkscape
27 ARCH=`arch`
28 PYTHON_VERS=`python -V 2>&1 | cut -c 8-10`
29 export PYTHONPATH="$TOP/python/site-packages/$ARCH/$PYTHON_VERS"
30 # NB: we are only preprending some stuff to the default python path so if the directory does not exist it should not harm the rest
32 # No longer required if path rewriting has been conducted.
33 # export DYLD_LIBRARY_PATH="$TOP/lib"
36 export FONTCONFIG_PATH="$TOP/etc/fonts"
37 export PANGO_RC_FILE="$HOME/.inkscape-etc/pangorc"
38 export GTK_IM_MODULE_FILE="$HOME/.inkscape-etc/gtk.immodules"
39 export GDK_PIXBUF_MODULE_FILE="$HOME/.inkscape-etc/gdk-pixbuf.loaders"
40 export GTK_DATA_PREFIX="$TOP"
41 export GTK_EXE_PREFIX="$TOP"
42 export GNOME_VFS_MODULE_CONFIG_PATH="$TOP/etc/gnome-vfs-2.0/modules"
43 export GNOME_VFS_MODULE_PATH="$TOP/lib/gnome-vfs-2.0/modules"
44 export XDG_DATA_DIRS="$TOP/share"
45 export ASPELL_CONF="prefix $TOP;"
47 # Note: This requires the path with the exact ImageMagic version number.
48 # FIXME: Make the osx-app.sh script write the version into this file when 
49 #        building the package.  Note, that ImageMagick will only work if 
50 #        it does not find a version installed into the same PREFIX as it
51 #        was originally installed.  Luckily, this is very unlikely given
52 #        the extra long and strangely named install prefix we use.
53 export MAGICK_CONFIGURE_PATH="$TOP/lib/ImageMagick-6.5.5/config:$TOP/share/ImageMagick-6.5.5/config"
54 export MAGICK_CODER_FILTER_PATH="$TOP/lib/ImageMagick-6.5.5/modules-Q16/filters"
55 export MAGICK_CODER_MODULE_PATH="$TOP/lib/ImageMagick-6.5.5/modules-Q16/coders"
57 export INKSCAPE_SHAREDIR="$TOP"
58 # TODO: move the share directory to a its own folder to make things a bit cleaner in the app bundle
59 export INKSCAPE_PLUGINDIR="$TOP/lib/inkscape"
60 export INKSCAPE_LOCALEDIR="$TOP/locale"
62 # Set GTK theme (only if there is no .gtkrc-2.0 in the user's home)
63 if [[ ! -e "$HOME/.gtkrc-2.0" ]]; then
64         # prepare the theme depending on OS X appearance settings
65         (
66                 cd "$INKSCAPE_SHAREDIR/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/"
67                 ./sync_osx_look.sh
68                 # TODO: make this more robust, probably by integrating this script directly inline here
69         )
70         export GTK2_RC_FILES="$INKSCAPE_SHAREDIR/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/gtkrc"
71 fi
73 # If the AppleCollationOrder preference doesn't exist, we fall back to using
74 # the AppleLocale preference.
75 LANGSTR=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null`
76 if [ "x$LANGSTR" == "x" ]
77 then
78     echo "Warning: AppleCollationOrder setting not found, using AppleLocale."
79     LANGSTR=`defaults read .GlobalPreferences AppleLocale 2>/dev/null | \
80             sed 's/_.*//'`
81 fi
83 # NOTE: Have to add ".UTF-8" to the LANG since omitting causes Inkscape
84 #       to crash on startup in locale_from_utf8().
85 export LANG="`grep \"\`echo $LANGSTR\`_\" /usr/share/locale/locale.alias | \
86         tail -n1 | sed 's/\./ /' | awk '{print $2}'`.UTF-8"
87 echo "Setting Language: $LANG"
89 # Handle the case where the directory storing Inkscape has a '#' in the name.
90 # This '#' needs to be escaped in pango.modules for Pango to work properly.
91 ESCAPEDTOP=`echo $TOP | sed 's/#/\\\\\\\\#/'`
93 mkdir -p "${HOME}/.inkscape-etc"
94 sed 's|${HOME}|'"$HOME|g" "$TOP/etc/pango/pangorc" > "${HOME}/.inkscape-etc/pangorc"
95 sed 's|${CWD}|'"$ESCAPEDTOP|g" "$TOP/etc/pango/pango.modules" \
96     > "${HOME}/.inkscape-etc/pango.modules"
97 cp -f "$TOP/etc/pango/pangox.aliases" "${HOME}/.inkscape-etc/"
98 sed 's|${CWD}|'"$TOP|g" "$TOP/etc/gtk-2.0/gtk.immodules" \
99     > "${HOME}/.inkscape-etc/gtk.immodules"
100 sed 's|${CWD}|'"$TOP|g" "$TOP/etc/gtk-2.0/gdk-pixbuf.loaders" \
101     > "${HOME}/.inkscape-etc/gdk-pixbuf.loaders"
103 exec "$CWD/inkscape-bin" "$@"