aadcae2137a82c28da5971ed654126799382ca63
[AGL/meta-agl.git] / meta-app-framework / recipes-core / af-main / af-main / afm-install
1 #!/bin/sh
2
3 pretty() {
4         sed \
5                 -e '/^method return .*/d' \
6                 -e 's/^Error org.freedesktop.DBus.Error.Failed: "\?\(.*\)"\?$/ERROR: \1/' \
7                 -e 's/^   string "\(.*\)"/\1/' \
8                 -e 's/},/&\n/'
9 }
10
11 send() {
12         dbus-send --system --print-reply \
13                 --dest=org.AGL.afm.system \
14                 /org/AGL/afm/system \
15                 org.AGL.afm.system.$1 \
16                 "string:$2" |
17         pretty
18         return ${PIPESTATUS[0]}
19 }
20
21 case "$1" in
22
23   add|install)
24     f=$(realpath $2)
25     send install '{"wgt":"'"$f"'","force":true,"reload":false}'
26     ;;
27
28   -h|--help|help)
29     cat << EOC
30
31 The commands are:
32
33   add wgt
34   install wgt    install the wgt file
35
36 EOC
37     ;;
38
39   *)
40     echo "unknown command $1" >&2
41     exit 1
42     ;;
43 esac
44
45