]> git.lyx.org Git - lyx.git/blob - development/MacOSX/inkscape
Add license info for inkscape start script
[lyx.git] / development / MacOSX / inkscape
1 #!/bin/bash
2
3 # \file inkscape
4 # wrapper start script for Inkscape.app on Mac
5 #
6 # This file is part of LyX, the document processor.
7 # Licence details can be found in the file COPYING.
8 #
9 # \author Stephan Witt
10 # Full author contact details are available in file CREDITS.
11
12 unset DISPLAY
13
14 # check for file arguments with relative path names
15 # convert them to absolute path names
16 # inkscape on Mac changes the working directory
17 # this invalidates relative path names
18 startinkscape() {
19         inkscape="$1" ; shift
20         pwd=$(pwd)
21         iparams=( "$@" )
22         oparams=()
23         for i in ${!iparams[@]}; do
24                 # echo $i "=>" "${iparams[$i]}"
25                 case "${iparams[$i]}" in
26                 --file=/*|--export-pdf=/*|--export-eps=/*|--export-png=/*|--export-emf=/*|--export-wmf=/*|--export-ps=/*|--export-ps-level=/*|--export-pdf-version=/*)
27                         oparams+=( "${iparams[$i]}" )
28                         ;;
29                 --file=*|--export-pdf=*|--export-eps=*|--export-png=*|--export-emf=*|--export-wmf=*|--export-ps=*|--export-ps-level=*|--export-pdf-version=*)
30                         oparams+=( "${iparams[$i]//=/=${pwd}/}" )
31                         ;;
32                 --without-gui|-z)
33                         # ignore this argument - its provided below anyway
34                         ;;
35                 *)
36                         oparams+=( "${iparams[$i]}" )
37                         ;;
38                 esac
39         done
40         exec "${inkscape}" --without-gui "${oparams[@]}"
41 }
42
43 # try to find the inkscape installation...
44 # at first try the well known location
45 RESDIR="/Applications/Inkscape.app/Contents/Resources"
46 if [ -f "${RESDIR}"/bin/inkscape -a -x "${RESDIR}"/bin/inkscape ]; then
47         startinkscape "${RESDIR}"/bin/inkscape "$@"
48         exit 0
49 fi
50 # this failed... so try PATH expansion to start the inkscape shell wrapper
51 IFS=":" read -ra DIRLIST <<< "${PATH}"
52 for BINDIR in "${DIRLIST[@]}" ; do
53         RESDIR=$(dirname "${BINDIR}")
54         if [ -f "${RESDIR}"/bin/inkscape -a -x "${RESDIR}"/bin/inkscape ]; then
55                 startinkscape "${RESDIR}"/bin/inkscape "$@"
56                 exit 0
57         fi
58 done
59 # report error and exit with failure status
60 exec 1>&2
61 echo Could not find Inkscape binary.
62 exit 1