afm-util: report correctly error status of dbus-send
[src/app-framework-main.git] / scripts / afm-util
index cc7ab55..9313b50 100755 (executable)
@@ -1,8 +1,9 @@
 #!/bin/sh
 
 if [ "x" = "x${DBUS_SESSION_BUS_ADDRESS}" ]; then
-       DBUS_SESSION_BUS_ADDRESS:=unix:path=/run/user/$UID/bus
+       DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$UID/bus"
 fi
+export DBUS_SESSION_BUS_ADDRESS
 
 pretty() {
        sed \
@@ -19,6 +20,7 @@ send() {
                org.AGL.afm.user.$1 \
                "string:$2" |
        pretty
+       return ${PIPESTATUS[0]}
 }
 
 case "$1" in
@@ -51,6 +53,16 @@ case "$1" in
     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"
@@ -58,12 +70,12 @@ case "$1" in
 
   stop|pause)
     i=$2
-    send stop "$i"
+    send pause "$i"
     ;;
 
   resume|continue)
     i=$2
-    send continue "$i"
+    send resume "$i"
     ;;
 
   state|status)
@@ -95,17 +107,19 @@ The commands are:
   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
+  terminate rid  terminate the running instance rid
 
   stop rid
-  pause rid      stop the running instance rid
+  pause rid      pause the running instance rid
 
   resume rid
-  continue rid   continue the previously rid
+  continue rid   continue the previously paused rid
 
   status rid
-  state rid     get status of the running instance rid
+  state rid      get status of the running instance rid
 
 EOC
     ;;