]> git.mdlowis.com Git - proto/labwc.git/commitdiff
labnag: return special value on timeout
authorJohan Malm <jgm323@gmail.com>
Sat, 9 Aug 2025 14:15:35 +0000 (15:15 +0100)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Mon, 11 Aug 2025 18:10:14 +0000 (03:10 +0900)
...to avoid taking either of the <then> or <else> branches on timeout.

clients/labnag.c
clients/meson.build
include/action-prompt-codes.h [new file with mode: 0644]
src/action.c

index fa3c3aea62572a4c2f84e83afb1631532ce1fbc6..7509d0659e56f47d0ea28ef1e8d1e2605e000f20 100644 (file)
 #include <wayland-client.h>
 #include <wayland-cursor.h>
 #include <wlr/util/log.h>
+#include "action-prompt-codes.h"
 #include "pool-buffer.h"
 #include "cursor-shape-v1-client-protocol.h"
 #include "wlr-layer-shell-unstable-v1-client-protocol.h"
 
 #define LABNAG_MAX_HEIGHT 500
-#define LAB_EXIT_FAILURE 255
-#define LAB_EXIT_SUCCESS 0
 
 struct conf {
        PangoFontDescription *font_description;
@@ -1239,6 +1238,7 @@ nag_run(struct nag *nag)
                        wl_display_cancel_read(nag->display);
                }
                if (nag->pollfds[FD_TIMER].revents & POLLIN) {
+                       exit_status = LAB_EXIT_TIMEOUT;
                        break;
                }
                if (nag->pollfds[FD_SIGNAL].revents & POLLIN) {
index 3a80a4f0ad02b259a235b4770119cbdf06398919..fefd5bd4b2f309aac8f70a2364565fec4ba90ef7 100644 (file)
@@ -50,6 +50,7 @@ executable(
     server_protos,
     epoll_dep,
   ],
+  include_directories: [labwc_inc],
        install: true
 )
 
diff --git a/include/action-prompt-codes.h b/include/action-prompt-codes.h
new file mode 100644 (file)
index 0000000..d1ca0f0
--- /dev/null
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef LABWC_ACTION_PROMPT_CODES_H
+#define LABWC_ACTION_PROMPT_CODES_H
+
+#define LAB_EXIT_FAILURE 255
+#define LAB_EXIT_TIMEOUT 254
+#define LAB_EXIT_SUCCESS 0
+
+#endif /* LABWC_ACTION_PROMPT_CODES_H */
index eb02708747b22743975ade493f7cc114b7d67eda..f377e3bde2cc7373302b9a0e7bc11096baa936f6 100644 (file)
@@ -8,6 +8,7 @@
 #include <unistd.h>
 #include <wlr/types/wlr_scene.h>
 #include <wlr/util/log.h>
+#include "action-prompt-codes.h"
 #include "common/macros.h"
 #include "common/list.h"
 #include "common/mem.h"
@@ -860,9 +861,11 @@ action_check_prompt_result(pid_t pid, int exit_code)
 
                wlr_log(WLR_INFO, "Found pending prompt for exit code %d", exit_code);
                struct wl_list *actions = NULL;
-               if (exit_code == 0) {
+               if (exit_code == LAB_EXIT_SUCCESS) {
                        wlr_log(WLR_INFO, "Selected the 'then' branch");
                        actions = action_get_actionlist(prompt->action, "then");
+               } else if (exit_code == LAB_EXIT_TIMEOUT) {
+                       /* no-op */
                } else {
                        wlr_log(WLR_INFO, "Selected the 'else' branch");
                        actions = action_get_actionlist(prompt->action, "else");