~ted/ubuntu-app-launch/uri-splitting

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
description "Application Launching Wrapper"
author "Ted Gould <ted@canonical.com>"

start on application-start

# Events aren't emitted directly, but start is used to create them
emits application-legacy-start
emits application-click-start

env APP_ID
export APP_ID

env APP_URIS
export APP_URIS

script
	CLICK_PKG=`echo "${APP_ID}" | cut -d _ -f 1`

	if [ ! -z $CLICK_PKG ] ; then
		CLICK_DIR=`click pkgdir "${CLICK_PKG}" || true`
	fi

	if [ ! -z $CLICK_DIR ] && [ -d $CLICK_DIR ] ; then
		if ! start application-click APP_ID="${APP_ID}" APP_URIS="${APP_URIS}"; then
			@pkglibexecdir@/second-exec
		fi
	else
		if @pkglibexecdir@/desktop-single $APP_ID ; then
			if ! start application-legacy APP_ID="${APP_ID}" INSTANCE_ID="" APP_URIS="${APP_URIS}" ; then
				@pkglibexecdir@/second-exec
			fi
		else
			start application-legacy APP_ID="${APP_ID}" INSTANCE_ID=`date -u +%s` APP_URIS="${APP_URIS}"
		fi
	fi
end script