blob: 170def6eb425e77fb015b5da058deb966ad89b13 (
plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#!/bin/sh
if [ "x" = "x${DBUS_SESSION_BUS_ADDRESS}" ]; then
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$UID/bus"
fi
export DBUS_SESSION_BUS_ADDRESS
pretty() {
sed ' /^method return .*/d
s/^Error org.freedesktop.DBus.Error.Failed: "\?\(.*\)"\?$/ERROR: \1/
s/^ string "\(.*\)"/\1/
s:[[{,]:&\n:g
s: *[]}]:\n&:g
' |
sed ' s:^ *::
s: *$::
/[]}],*$/ {x;s:...::;x}
G
/[[{]\n/ {x;s:$: :;x}
s:^\(.*[^\n]\)\n\( *\)$:\2\1:
'
}
send() {
dbus-send --session --print-reply \
--dest=org.AGL.afm.user \
/org/AGL/afm/user \
org.AGL.afm.user.$1 \
"string:$2" |
pretty
return ${PIPESTATUS[0]}
}
case "$1" in
list|runnables)
send runnables true
;;
add|install)
f=$(realpath $2)
send install '{"wgt":"'"$f"'","force":true}'
;;
remove|uninstall)
i=$2
send uninstall "\"$i\""
;;
info|detail)
i=$2
send detail "\"$i\""
;;
ps|runners)
send runners true
;;
run|start)
i=$2
send start "\"$i\""
;;
run-remote|start-remote)
i=$2
send start '{"id":"'"$i"'","mode":"remote"}'
;;
once)
i=$2
send once "\"$i\""
;;
terminate|kill)
i=$2
send terminate "$i"
;;
stop|pause)
i=$2
send pause "$i"
;;
resume|continue)
i=$2
send resume "$i"
;;
state|status)
i=$2
send state "$i"
;;
-h|--help|help)
cat << EOC
usage: $(basename $0) command [arg]
The commands are:
list
runnables list the runnable widgets installed
add wgt
install wgt install the wgt file
remove id
uninstall id remove the installed widget of id
info id
detail id print detail about the installed widget of id
ps
runners list the running instance
run id
start id start an instance of the widget of id
once id run once an instance of the widget of id
kill rid
terminate rid terminate the running instance rid
stop rid
pause rid pause the running instance rid
resume rid
continue rid continue the previously paused rid
status rid
state rid get status of the running instance rid
EOC
;;
*)
echo "unknown command $1" >&2
exit 1
;;
esac
|