swaybar: send signal to status when hiding or showing bar

This commit is contained in:
Ian Fan 2018-10-12 20:59:45 +01:00
parent f6f72cb949
commit a29ee77411
3 changed files with 21 additions and 0 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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);