From 4ce16084ff2a813dfa6f1d3bdf4ef5a82e092aac Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 31 Aug 2016 15:53:27 +0200 Subject: [PATCH 1/2] awesome-client: Handle errors when running arguments Commit 78abb4a54cf58db21396cedc34f0aa46827212ff made awesome-client fail with a non-zero exit code when sending a command that it got from stdin failed. Commit f0f31bc305881aa0df54d66477843ffd475cb316 added the possibility to specify commands to run as arguments to awesome-client. However, the exit code was still zero even when such a command failed. This commit makes awesome-client signal errors with its exit code even for code specified via arguments. Note that this means that following arguments will not be executed if some argument fails. I do not know if this is the best behaviour or not, but I am implementing it like this here due to its simplicity to implement. Signed-off-by: Uli Schlachter --- utils/awesome-client | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/awesome-client b/utils/awesome-client index 28ed5703..7d61603b 100755 --- a/utils/awesome-client +++ b/utils/awesome-client @@ -44,14 +44,16 @@ a_dbus_send() $DBUS_SEND --dest=$DBUS_DEST --type=method_call --print-reply \ $DBUS_PATH $DBUS_METHOD string:"$1" | tail -n +2 ret=$? - if [ "$ret" != 0 ] && [ "$ISATTY" != 0 ]; then + if [ "$ret" != 0 ] && [ "$FATAL_ERRORS" != 0 ]; then echo "E: $DBUS_SEND failed." >&2 exit $ret fi } +FATAL_ERRORS="$ISATTY" if [ $# -ne 0 ] then + FATAL_ERRORS="1" for arg in "$@" ; do a_dbus_send "$arg" done From cf89f108aca88e1257cba1defea279af4a447bd3 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Tue, 30 Aug 2016 18:00:35 +0200 Subject: [PATCH 2/2] Make use of awesome-client commands This uses the new support introduced in f0f31bc30588 in the docs and in tests/run.sh, removing an useless use of cat/echo. Signed-off-by: Uli Schlachter --- docs/90-FAQ.md | 6 +++--- tests/run.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/90-FAQ.md b/docs/90-FAQ.md index 9f2a4060..0cc6c46a 100644 --- a/docs/90-FAQ.md +++ b/docs/90-FAQ.md @@ -304,10 +304,10 @@ the upper right corner of the screen. ### How to restart or quit awesome? You can use the keybinding "Mod4+Ctrl+r" or by selecting restart in the menu. -You could call `awesome.restart` either from the Lua prompt widget, or by -passing it to `awesome-client`: +You could call `awesome.restart` either from the Lua prompt widget, or via +`awesome-client`: - $ echo 'awesome.restart()' | awesome-client + $ awesome-client 'awesome.restart()' You can also send the `SIGHUP` signal to the awesome process. Find the PID using `ps`, `pgrep` or use `pkill`: diff --git a/tests/run.sh b/tests/run.sh index 19de1486..51702184 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -188,7 +188,7 @@ start_awesome() { cd - >/dev/null # Wait until the interface for awesome-client is ready (D-Bus interface). - wait_until_success "wait for awesome startup via awesome-client" "echo 'return 1' | DISPLAY=$D '$AWESOME_CLIENT' 2>&1" + wait_until_success "wait for awesome startup via awesome-client" "DISPLAY=$D '$AWESOME_CLIENT' 'return 1' 2>&1" } # Count errors.