File: inkscape

package info (click to toggle)
lyx 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 138,444 kB
  • sloc: cpp: 244,268; ansic: 106,398; xml: 72,791; python: 39,384; sh: 7,666; makefile: 6,584; pascal: 2,143; perl: 2,101; objc: 1,084; tcl: 163; sed: 16
file content (72 lines) | stat: -rwxr-xr-x 2,389 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash

# \file inkscape
# wrapper start script for Inkscape.app on Mac
#
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# \author Stephan Witt
# Full author contact details are available in file CREDITS.

unset DISPLAY

# check for file arguments with relative path names
# convert them to absolute path names
# inkscape on Mac changes the working directory
# this invalidates relative path names
startinkscape() {
	inkscape="$1" ; shift
	pwd=$(pwd)
	iparams=( "$@" )
	oparams=()
	# pre 1.0 application has cmd line utility in resources
	# this utility needs the explicit option to suppress gui
	# 1.0 don't have it and fails to start with it
	case "${inkscape}" in
	*/Resources/*)
		wogui="--without-gui"
		;;
	esac
	for i in ${!iparams[@]}; do
		# echo $i "=>" "${iparams[$i]}"
		case "${iparams[$i]}" in
		--file=/*|--export-pdf=/*|--export-eps=/*|--export-png=/*|--export-emf=/*|--export-wmf=/*|--export-ps=/*|--export-ps-level=/*|--export-pdf-version=/*)
			oparams+=( "${iparams[$i]}" )
			;;
		--file=*|--export-pdf=*|--export-eps=*|--export-png=*|--export-emf=*|--export-wmf=*|--export-ps=*|--export-ps-level=*|--export-pdf-version=*)
			oparams+=( "${iparams[$i]//=/=${pwd}/}" )
			;;
		--without-gui|-z)
			# ignore this argument - its provided below anyway
			;;
		*)
			oparams+=( "${iparams[$i]}" )
			;;
		esac
	done
	exec "${inkscape}" ${wogui} "${oparams[@]}"
}

# try to find the inkscape installation...
# at first try the well known location for Inkscape 1.0
# but check for Inkscape 0.92.x too and skip this if it's in Resources
RESDIR="/Applications/Inkscape.app/Contents/MacOS"
if [ ! -f "/Applications/Inkscape.app/Contents/Resources/bin/inkscape" -a -f "${RESDIR}"/inkscape -a -x "${RESDIR}"/inkscape ]; then
	startinkscape "${RESDIR}"/inkscape "$@"
	exit 0
fi
# this failed... so try PATH expansion to start the inkscape shell wrapper
# Now continue the check with pre 1.0 inkscape application and the PATH
IFS=":" read -ra DIRLIST <<< "${PATH}"
for BINDIR in "/Applications/Inkscape.app/Contents/Resources/bin" "${DIRLIST[@]}" ; do
	RESDIR=$(dirname "${BINDIR}")
	if [ -f "${RESDIR}"/bin/inkscape -a -x "${RESDIR}"/bin/inkscape ]; then
		startinkscape "${RESDIR}"/bin/inkscape "$@"
		exit 0
	fi
done
# report error and exit with failure status
exec 1>&2
echo Could not find Inkscape binary.
exit 1