-
Notifications
You must be signed in to change notification settings - Fork 2
/
my-awesome-app
executable file
·56 lines (50 loc) · 1.79 KB
/
my-awesome-app
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
#!/usr/bin/env bash
# A demonstration app for Snapcraft Template Plus, essentially only show a friendly message
#
# Copyright 2019 林博仁(Buo-ren, Lin) <[email protected]>
# SPDX-License-Identifier: MIT
set \
-o errexit \
-o errtrace \
-o nounset \
-o pipefail
if [ -v 'BASH_SOURCE[0]' ]; then
RUNTIME_EXECUTABLE_PATH="$(realpath --strip "${BASH_SOURCE[0]}")"
RUNTIME_EXECUTABLE_FILENAME="$(basename "${RUNTIME_EXECUTABLE_PATH}")"
RUNTIME_EXECUTABLE_NAME="${RUNTIME_EXECUTABLE_FILENAME%.*}"
RUNTIME_EXECUTABLE_DIRECTORY="$(dirname "${RUNTIME_EXECUTABLE_PATH}")"
RUNTIME_COMMANDLINE_BASECOMMAND="${0}"
# We intentionally leaves these variables for script developers
# shellcheck disable=SC2034
declare -r \
RUNTIME_EXECUTABLE_PATH \
RUNTIME_EXECUTABLE_FILENAME \
RUNTIME_EXECUTABLE_NAME \
RUNTIME_EXECUTABLE_DIRECTORY \
RUNTIME_COMMANDLINE_BASECOMMAND
fi
declare -ar RUNTIME_COMMANDLINE_ARGUMENTS=("${@}")
init(){
local icon
# HACK: Allow testing the script in-place
if ! test -v SNAP; then
icon="${RUNTIME_EXECUTABLE_DIRECTORY}"/snap/gui/my-awesome-app.png
else
icon="${SNAP}"/meta/gui/my-awesome-app.png
fi
zenity \
--info \
--ok-label='Got it!' \
--title='My Awesome App.' \
--text='This is a demonstrative application for Snapcrafters Template Plus.\nIt indicates that the snapped application has been launched properly.' \
--window-icon="${icon}" \
--width=600
exit $?
}
# WORKAROUND: `@` expansion triggeres unbound variable error in Bash 4.3(Ubuntu 16.04)
# http://mywiki.wooledge.org/BashFAQ/112#Negatives
if test "${#RUNTIME_COMMANDLINE_ARGUMENTS[@]}" -ne 0; then
init "${RUNTIME_COMMANDLINE_ARGUMENTS[@]}"
else
init
fi