aboutsummaryrefslogtreecommitdiff
path: root/include/watcher.h
diff options
context:
space:
mode:
authorPhilip Wittamore <philip@wittamore.com>2025-06-08 22:00:43 +0200
committerPhilip Wittamore <philip@wittamore.com>2025-06-08 22:00:43 +0200
commit81757c235ff8e112b4baabdd1ff23409426e9c98 (patch)
treeef213566ac3c17bf3d7795b0597f254791bd219e /include/watcher.h
downloaddwmblocks-async-81757c235ff8e112b4baabdd1ff23409426e9c98.tar.gz
dwmblocks-async-81757c235ff8e112b4baabdd1ff23409426e9c98.tar.bz2
dwmblocks-async-81757c235ff8e112b4baabdd1ff23409426e9c98.zip
update
Diffstat (limited to 'include/watcher.h')
-rw-r--r--include/watcher.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/watcher.h b/include/watcher.h
new file mode 100644
index 0000000..ff31809
--- /dev/null
+++ b/include/watcher.h
@@ -0,0 +1,28 @@
+#ifndef WATCHER_H
+#define WATCHER_H
+
+#include <poll.h>
+#include <stdbool.h>
+
+#include "block.h"
+#include "main.h"
+
+enum watcher_fd_index {
+ SIGNAL_FD = BLOCK_COUNT,
+ WATCHER_FD_COUNT,
+};
+
+typedef struct pollfd watcher_fd;
+
+typedef struct {
+ watcher_fd fds[WATCHER_FD_COUNT];
+ unsigned short active_blocks[BLOCK_COUNT];
+ unsigned short active_block_count;
+ bool got_signal;
+} watcher;
+
+int watcher_init(watcher *const watcher, const block *const blocks,
+ const unsigned short block_count, const int signal_fd);
+int watcher_poll(watcher *const watcher, const int timeout_ms);
+
+#endif // WATCHER_H