diff --git a/include/swaybar/status_line.h b/include/swaybar/status_line.h index ca88b0c5..5e7e8771 100644 --- a/include/swaybar/status_line.h +++ b/include/swaybar/status_line.h @@ -22,6 +22,9 @@ struct status_line { const char *text; struct wl_list blocks; // i3bar_block::link + int stop_signal; + int cont_signal; + bool click_events; bool clicked; char *buffer; diff --git a/swaybar/bar.c b/swaybar/bar.c index 6894383d..f636f0c9 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -396,6 +396,10 @@ bool determine_bar_visibility(struct swaybar *bar, bool moving_layer) { destroy_layer_surface(output); } } + wlr_log(WLR_DEBUG, "Sending %s signal to status command", + visible ? "cont" : "stop"); + kill(bar->status->pid, + visible ? bar->status->cont_signal : bar->status->stop_signal); } return visible; } diff --git a/swaybar/status_line.c b/swaybar/status_line.c index ed6dc7c8..000609ce 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c @@ -83,6 +83,17 @@ bool status_handle_readable(struct status_line *status) { return true; } } + + json_object *signal; + if (json_object_object_get_ex(header, "stop_signal", &signal)) { + status->stop_signal = json_object_get_int(signal); + wlr_log(WLR_DEBUG, "Setting stop signal to %d", status->stop_signal); + } + if (json_object_object_get_ex(header, "cont_signal", &signal)) { + status->cont_signal = json_object_get_int(signal); + wlr_log(WLR_DEBUG, "Setting cont signal to %d", status->cont_signal); + } + json_object_put(header); wl_list_init(&status->blocks); @@ -121,6 +132,9 @@ bool status_handle_readable(struct status_line *status) { struct status_line *status_line_init(char *cmd) { struct status_line *status = calloc(1, sizeof(struct status_line)); + status->stop_signal = SIGSTOP; + status->cont_signal = SIGCONT; + status->buffer_size = 8192; status->buffer = malloc(status->buffer_size);