diff options
author | Ian Fan <ianfan0@gmail.com> | 2018-10-12 20:59:45 +0100 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2018-10-14 13:33:12 +0100 |
commit | a29ee77411be3f3fe988617d91cc5bed603e3dcb (patch) | |
tree | a802fd48bb2ea28a8bf972b49ce1eec9f0d38447 | |
parent | swaybar: show hidden bar on urgency (diff) | |
download | sway-a29ee77411be3f3fe988617d91cc5bed603e3dcb.tar.gz sway-a29ee77411be3f3fe988617d91cc5bed603e3dcb.tar.zst sway-a29ee77411be3f3fe988617d91cc5bed603e3dcb.zip |
swaybar: send signal to status when hiding or showing bar
-rw-r--r-- | include/swaybar/status_line.h | 3 | ||||
-rw-r--r-- | swaybar/bar.c | 4 | ||||
-rw-r--r-- | swaybar/status_line.c | 14 |
3 files changed, 21 insertions, 0 deletions
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 { | |||
22 | const char *text; | 22 | const char *text; |
23 | struct wl_list blocks; // i3bar_block::link | 23 | struct wl_list blocks; // i3bar_block::link |
24 | 24 | ||
25 | int stop_signal; | ||
26 | int cont_signal; | ||
27 | |||
25 | bool click_events; | 28 | bool click_events; |
26 | bool clicked; | 29 | bool clicked; |
27 | char *buffer; | 30 | 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) { | |||
396 | destroy_layer_surface(output); | 396 | destroy_layer_surface(output); |
397 | } | 397 | } |
398 | } | 398 | } |
399 | wlr_log(WLR_DEBUG, "Sending %s signal to status command", | ||
400 | visible ? "cont" : "stop"); | ||
401 | kill(bar->status->pid, | ||
402 | visible ? bar->status->cont_signal : bar->status->stop_signal); | ||
399 | } | 403 | } |
400 | return visible; | 404 | return visible; |
401 | } | 405 | } |
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) { | |||
83 | return true; | 83 | return true; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | |||
87 | json_object *signal; | ||
88 | if (json_object_object_get_ex(header, "stop_signal", &signal)) { | ||
89 | status->stop_signal = json_object_get_int(signal); | ||
90 | wlr_log(WLR_DEBUG, "Setting stop signal to %d", status->stop_signal); | ||
91 | } | ||
92 | if (json_object_object_get_ex(header, "cont_signal", &signal)) { | ||
93 | status->cont_signal = json_object_get_int(signal); | ||
94 | wlr_log(WLR_DEBUG, "Setting cont signal to %d", status->cont_signal); | ||
95 | } | ||
96 | |||
86 | json_object_put(header); | 97 | json_object_put(header); |
87 | 98 | ||
88 | wl_list_init(&status->blocks); | 99 | wl_list_init(&status->blocks); |
@@ -121,6 +132,9 @@ bool status_handle_readable(struct status_line *status) { | |||
121 | 132 | ||
122 | struct status_line *status_line_init(char *cmd) { | 133 | struct status_line *status_line_init(char *cmd) { |
123 | struct status_line *status = calloc(1, sizeof(struct status_line)); | 134 | struct status_line *status = calloc(1, sizeof(struct status_line)); |
135 | status->stop_signal = SIGSTOP; | ||
136 | status->cont_signal = SIGCONT; | ||
137 | |||
124 | status->buffer_size = 8192; | 138 | status->buffer_size = 8192; |
125 | status->buffer = malloc(status->buffer_size); | 139 | status->buffer = malloc(status->buffer_size); |
126 | 140 | ||