mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-24 21:05:40 +02:00
module: add new function module_signal_ready()
This commit is contained in:
parent
a3eb7ebc08
commit
3413232ed6
9 changed files with 19 additions and 14 deletions
5
bar.c
5
bar.c
|
@ -417,7 +417,10 @@ run(struct bar_run_context *run_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DBG("waiting for modules to become ready");
|
LOG_DBG("waiting for modules to become ready");
|
||||||
for (size_t i = 0; i < bar->left.count + bar->center.count + bar->right.count; i++) {
|
|
||||||
|
for (size_t i = 0; i < (bar->left.count +
|
||||||
|
bar->center.count +
|
||||||
|
bar->right.count); i++) {
|
||||||
uint64_t b;
|
uint64_t b;
|
||||||
read(ready_fd, &b, sizeof(b));
|
read(ready_fd, &b, sizeof(b));
|
||||||
}
|
}
|
||||||
|
|
8
module.c
8
module.c
|
@ -1,5 +1,7 @@
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
struct module *
|
struct module *
|
||||||
module_common_new(void)
|
module_common_new(void)
|
||||||
|
@ -24,6 +26,12 @@ module_default_destroy(struct module *mod)
|
||||||
free(mod);
|
free(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
module_signal_ready(struct module_run_context *ctx)
|
||||||
|
{
|
||||||
|
write(ctx->ready_fd, &(uint64_t){1}, sizeof(uint64_t));
|
||||||
|
}
|
||||||
|
|
||||||
struct module_expose_context
|
struct module_expose_context
|
||||||
module_default_begin_expose(struct module *mod, cairo_t *cr)
|
module_default_begin_expose(struct module *mod, cairo_t *cr)
|
||||||
{
|
{
|
||||||
|
|
1
module.h
1
module.h
|
@ -39,6 +39,7 @@ struct module {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct module *module_common_new(void);
|
struct module *module_common_new(void);
|
||||||
|
void module_signal_ready(struct module_run_context *ctx);
|
||||||
|
|
||||||
void module_default_destroy(struct module *mod);
|
void module_default_destroy(struct module *mod);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -203,7 +202,7 @@ run(struct module_run_context *ctx)
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
|
||||||
udev_monitor_enable_receiving(mon);
|
udev_monitor_enable_receiving(mon);
|
||||||
|
|
||||||
write(ctx->ready_fd, &(uint64_t){1}, sizeof(uint64_t));
|
module_signal_ready(ctx);
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
@ -52,7 +50,7 @@ run(struct module_run_context *ctx)
|
||||||
{
|
{
|
||||||
const struct bar *bar = ctx->module->bar;
|
const struct bar *bar = ctx->module->bar;
|
||||||
|
|
||||||
write(ctx->ready_fd, &(uint64_t){1}, sizeof(uint64_t));
|
module_signal_ready(ctx);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -287,7 +286,7 @@ run(struct module_run_context *ctx)
|
||||||
send_pkg(sock, I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL);
|
send_pkg(sock, I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL);
|
||||||
send_pkg(sock, I3_IPC_MESSAGE_TYPE_SUBSCRIBE, "[\"workspace\"]");
|
send_pkg(sock, I3_IPC_MESSAGE_TYPE_SUBSCRIBE, "[\"workspace\"]");
|
||||||
|
|
||||||
write(ctx->ready_fd, &(uint64_t){1}, sizeof(uint64_t));
|
module_signal_ready(ctx);
|
||||||
|
|
||||||
char buf[1 * 1024 * 1024]; /* Some replies are *big*. TODO: grow dynamically */
|
char buf[1 * 1024 * 1024]; /* Some replies are *big*. TODO: grow dynamically */
|
||||||
size_t buf_idx = 0;
|
size_t buf_idx = 0;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
@ -30,7 +28,7 @@ content(struct module *mod)
|
||||||
static int
|
static int
|
||||||
run(struct module_run_context *ctx)
|
run(struct module_run_context *ctx)
|
||||||
{
|
{
|
||||||
write(ctx->ready_fd, &(uint64_t){1}, sizeof(uint64_t));
|
module_signal_ready(ctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
@ -439,7 +438,7 @@ run(struct module_run_context *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: move this to later */
|
/* TODO: move this to later */
|
||||||
write(ctx->ready_fd, &(uint64_t){1}, sizeof(uint64_t));
|
module_signal_ready(ctx);
|
||||||
|
|
||||||
int ret = talk_to_xkb(ctx->abort_fd, ctx->module->bar, ctx->module->private, conn)
|
int ret = talk_to_xkb(ctx->abort_fd, ctx->module->bar, ctx->module->private, conn)
|
||||||
? EXIT_SUCCESS : EXIT_FAILURE;
|
? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
|
|
@ -207,7 +207,7 @@ run(struct module_run_context *ctx)
|
||||||
update_title(m);
|
update_title(m);
|
||||||
mod->bar->refresh(mod->bar);
|
mod->bar->refresh(mod->bar);
|
||||||
|
|
||||||
write(ctx->ready_fd, &(uint64_t){1}, sizeof(uint64_t));
|
module_signal_ready(ctx);
|
||||||
|
|
||||||
int xcb_fd = xcb_get_file_descriptor(m->conn);
|
int xcb_fd = xcb_get_file_descriptor(m->conn);
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue