-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplayline.bash
More file actions
executable file
·40 lines (34 loc) · 963 Bytes
/
displayline.bash
File metadata and controls
executable file
·40 lines (34 loc) · 963 Bytes
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
#!/bin/bash
# Usage: displayline [-g|--background] LINE PDFFILE [TEXSOURCEFILE]
# Parse options
ACTIVATE="activate"
while [[ "${1:0:1}" == "-" ]]; do
if [[ "$1" == "-g" || "$1" == "-background" || "$1" == "--background" ]]; then
ACTIVATE=""
fi
shift
done
if [ $# -lt 2 ]; then
echo "Usage: displayline [-g|--background] LINE PDFFILE [TEXSOURCEFILE]"
exit 1
fi
LINE=$1
PDF=$2
SRC=$3
# Expand relative path to absolute path
[[ "${PDF:0:1}" == "/" ]] || PDF="${PWD}/${PDF}"
# Construct arguments if a source file is specified
if [ -n "$SRC" ]; then
[[ "${SRC:0:1}" == "/" ]] || SRC="${PWD}/${SRC}"
# Add as an AppleScript keyword parameter 'srcF'
SRC_ARG=", «class srcF»:\"${SRC}\""
else
SRC_ARG=""
fi
# Send custom event 'GLLYfwdj' with named parameters
/usr/bin/osascript << EOF
tell application "GalleyPDF"
${ACTIVATE}
«event GLLYfwdj» "${LINE}" given «class pdfP»:"${PDF}"${SRC_ARG}
end tell
EOF