diff options
| author | Federico Angelilli <code@fedang.net> | 2024-03-07 23:46:52 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-03-07 23:46:52 +0100 |
| commit | 04275df210744923651c6119e64301a8e2d45e77 (patch) | |
| tree | 01d1a867cd2d177598dddb4911bda1da3cbde99e /src | |
| parent | f7e94e7a0f33cbf6b5ee784974a431d633aada0f (diff) | |
Make dwm ipc optional
Diffstat (limited to 'src')
| -rw-r--r-- | src/comet.c | 1 | ||||
| -rw-r--r-- | src/dwm.c | 14 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/comet.c b/src/comet.c index a969677..aacf89c 100644 --- a/src/comet.c +++ b/src/comet.c @@ -292,7 +292,6 @@ int main(int argc, char **argv) // Dwm tags DwmIpc *dwm = dwm_create(state, "/tmp/dwm.sock"); - dwm_register_tags(dwm, color, purple, text_color, line_color); register_buttons(state, color, line_color, text_color); @@ -316,7 +316,13 @@ DwmIpc *dwm_create(State *state, const char *socket) GSocketAddress *addr = g_unix_socket_address_new(socket); if (!g_socket_connect(dwm->socket, addr, NULL, &error)) { g_assert_nonnull(error); - log_error("Failed to connect to %s: %s", socket, error->message); + log_debug("Failed to connect socket %s: %s", socket, error->message); + log_info("Skipped dwm ipc [socket=%s]", socket); + + g_error_free(error); + g_object_unref(dwm->socket); + g_free(dwm); + return NULL; } dwm->source = g_socket_create_source(dwm->socket, G_IO_IN, NULL); @@ -335,7 +341,7 @@ DwmIpc *dwm_create(State *state, const char *socket) ipc_subscribe(dwm, events[i]); g_source_attach(dwm->source, NULL); - log_debug("Attached dwm ipc source"); + log_info("Attached dwm ipc source [socket=%s]", socket); return dwm; } @@ -359,6 +365,8 @@ static void change_tag_action(Button *btn) void dwm_register_tags(DwmIpc *dwm, Color color, Color selected, Color text_color, Color line_color) { + if (dwm == NULL) return; + dwm->color = color; dwm->text_color = text_color; dwm->selected = selected; @@ -378,6 +386,8 @@ void dwm_register_tags(DwmIpc *dwm, Color color, Color selected, Color text_colo void dwm_destroy(DwmIpc *dwm) { + if (dwm == NULL) return; + g_source_destroy(dwm->source); g_source_unref(dwm->source); g_object_unref(dwm->socket); |
