f5da0e1e52dfec8537bb032de043536990b25650
[src/app-framework-main.git] / scripts / afm-util
1 #!/bin/sh
2
3 if [ "x" = "x${DBUS_SESSION_BUS_ADDRESS}" ]; then
4         DBUS_SESSION_BUS_ADDRESS:=unix:path=/run/user/$UID/bus
5 fi
6
7 send() {
8         dbus-send --session --dest=org.AGL.afm.user --print-reply /org/AGL/afm/user org.AGL.afm.user.$1 "string:$2"
9 }
10
11 case "$1" in
12
13   list|runnables)
14     send runnables true
15     ;;
16
17   add|install)
18     f=$(realpath $2)
19     send install '{"wgt":"'"$f"'","force":true}'
20     ;;
21
22   remove|uninstall)
23     i=$2
24     send uninstall "\"$i\""
25     ;;
26
27   info|detail)
28     i=$2
29     send detail "\"$i\""
30     ;;
31
32   ps|runners)
33     send runners true
34     ;;
35
36   run|start)
37     i=$2
38     send start "\"$i\""
39     ;;
40
41   terminate|kill)
42     i=$2
43     send terminate "$i"
44     ;;
45
46   stop|pause)
47     i=$2
48     send stop "$i"
49     ;;
50
51   resume|continue)
52     i=$2
53     send continue "$i"
54     ;;
55
56   state|status)
57     i=$2
58     send state "$i"
59     ;;
60
61   -h|--help|help)
62     cat << EOC
63 usage: $(basename $0) command [arg]
64
65 The commands are:
66
67   list
68   runnables      list the runnable widgets installed
69
70   add wgt
71   install wgt    install the wgt file
72
73   remove id
74   uninstall id   remove the installed widget of id
75
76   info id
77   detail id      print detail about the installed widget of id
78
79   ps
80   runners        list the running instance
81
82   run id
83   start id       start an instance of the widget of id
84
85   terminate rid
86   kill rid       terminate the running instance rid
87
88   stop rid
89   pause rid      stop the running instance rid
90
91   resume rid
92   continue rid   continue the previously rid
93
94   state rid
95   status rid     get status of the running instance rid
96
97 EOC
98     ;;
99
100   *)
101     echo "unknown command $1" >&2
102     exit 1
103     ;;
104 esac
105
106