From b9b47c7741ff9c4e09190e40669e015a740ecf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Sun, 12 Jan 2025 04:11:53 +0500 Subject: [PATCH] Allow doing actions on "w" end. --- dobroho_vechora.bash | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/dobroho_vechora.bash b/dobroho_vechora.bash index 55474fe..b4726ae 100755 --- a/dobroho_vechora.bash +++ b/dobroho_vechora.bash @@ -73,6 +73,19 @@ print_messages() { close_socket } +wait_for_messages() { + oldlength="${length}" + while :; do + length="$(get_message 1)" + if [ "${oldlength}" -ne "${length}" ]; then + break + fi + echo -n . + sleep 1 + done + echo +} + length=0 while :; do read cmd @@ -101,17 +114,11 @@ while :; do echo "${length}" ;; w) - oldlength="${length}" - while :; do - length="$(get_message 1)" - if [ "${oldlength}" -ne "${length}" ]; then - break - fi - echo -n . - sleep 1 - done - echo + wait_for_messages print_messages "${length}" + if [ -n "${DOBROHO_VECHORA_ON_WAIT}" ]; then + ${DOBROHO_VECHORA_ON_WAIT} + fi ;; p) length="$(get_message 1)"