afm-util: install and pretty printing
authorJosé Bollo <jose.bollo@iot.bzh>
Tue, 15 Mar 2016 08:57:03 +0000 (09:57 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 15 Mar 2016 08:57:03 +0000 (09:57 +0100)
Change-Id: I00cadda36c71495c352cfee9bfd4540f5defc89e
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
CMakeLists.txt
scripts/CMakeLists.txt [new file with mode: 0644]
scripts/afm-util

index 48cb270..ebae7fc 100644 (file)
@@ -57,5 +57,6 @@ defstr(FWK_LAUNCH_CONF         "${afm_confdir}/afm-launch.conf")
 
 add_subdirectory(src)
 add_subdirectory(conf)
+add_subdirectory(scripts)
 
 
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
new file mode 100644 (file)
index 0000000..74ecec7
--- /dev/null
@@ -0,0 +1,22 @@
+###########################################################################
+# Copyright 2015 IoT.bzh
+#
+# author: José Bollo <jose.bollo@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+cmake_minimum_required(VERSION 2.8)
+
+install(PROGRAMS afm-util DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
+
index f5da0e1..cc7ab55 100755 (executable)
@@ -4,8 +4,21 @@ if [ "x" = "x${DBUS_SESSION_BUS_ADDRESS}" ]; then
        DBUS_SESSION_BUS_ADDRESS:=unix:path=/run/user/$UID/bus
 fi
 
+pretty() {
+       sed \
+               -e '/^method return .*/d' \
+               -e 's/^Error org.freedesktop.DBus.Error.Failed: "\?\(.*\)"\?$/ERROR: \1/' \
+               -e 's/^   string "\(.*\)"/\1/' \
+               -e 's/},/&\n/'
+}
+
 send() {
-       dbus-send --session --dest=org.AGL.afm.user --print-reply /org/AGL/afm/user org.AGL.afm.user.$1 "string:$2"
+       dbus-send --session --print-reply \
+               --dest=org.AGL.afm.user \
+               /org/AGL/afm/user \
+               org.AGL.afm.user.$1 \
+               "string:$2" |
+       pretty
 }
 
 case "$1" in
@@ -82,8 +95,8 @@ The commands are:
   run id
   start id       start an instance of the widget of id
 
-  terminate rid
-  kill rid       terminate the running instance rid
+  kill rid
+  terminate rid       terminate the running instance rid
 
   stop rid
   pause rid      stop the running instance rid
@@ -91,8 +104,8 @@ The commands are:
   resume rid
   continue rid   continue the previously rid
 
-  state rid
-  status rid     get status of the running instance rid
+  status rid
+  state rid     get status of the running instance rid
 
 EOC
     ;;