-
Notifications
You must be signed in to change notification settings - Fork 15
/
connector-osx-kn6.sh
executable file
·49 lines (45 loc) · 1.46 KB
/
connector-osx-kn6.sh
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
#!/bin/sh
##
## slideshow -- Observe and Control Slideshow Applications
## Copyright (c) 2014-2023 Dr. Ralf S. Engelschall <http://engelschall.com>
##
## This Source Code Form is subject to the terms of the Mozilla Public
## License (MPL), version 2.0. If a copy of the MPL was not distributed
## with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
##
## File: connector-osx-kn6.sh
## Purpose: connector wrapper for Apple Keynote 6 under Mac OS X
## Language: Bourne-Shell
##
# determine base directory
case "$0" in
/* ) basedir=`echo $0 | sed -e 's;/[^/][^/]*$;;'` ;;
*/* ) basedir="`pwd`/`echo $0 | sed -e 's;/[^/][^/]*$;;'`" ;;
* )
OIFS=$IFS; IFS=":"
for dir in $PATH; do
IFS=$OIFS
if [ -x "$dir/$0" ]; then
basedir=$dir
break
fi
done
IFS=$OIFS
;;
esac
basedir=`echo "$basedir" | sed -e 's;/\.$;;g'`
basedir=`echo "$basedir" | sed -e 's;/\./;/;g'`
basedir=`echo "$basedir" | sed -e 's;/[^/][^/]*/\.\./;/;g'`
basedir=`echo "$basedir" | sed -e 's;/[^/][^/]*/\.\.$;;g'`
# provide the stdin loop
# (because AppleScript is not easily able to do this)
while true; do
# read request
read request
if [ ".$request" = . ]; then
break
fi
command=`echo "$request" | sed -e 's;^.*command": *"\([^"]*\)".*$;\1;'`
# let AppleScript produce the response
osascript "$basedir/connector-osx-kn6.scpt" $command
done