aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/swaybar/bar.h2
-rw-r--r--swaybar/bar.c2
-rw-r--r--swaybar/tray/host.c2
-rw-r--r--swaybar/tray/item.c13
4 files changed, 18 insertions, 1 deletions
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h
index ad942242..e377b8de 100644
--- a/include/swaybar/bar.h
+++ b/include/swaybar/bar.h
@@ -88,6 +88,8 @@ bool bar_setup(struct swaybar *bar, const char *socket_path);
void bar_run(struct swaybar *bar);
void bar_teardown(struct swaybar *bar);
+void set_bar_dirty(struct swaybar *bar);
+
/*
* Determines whether the bar should be visible and changes it to be so.
* If the current visibility of the bar is the different to what it should be,
diff --git a/swaybar/bar.c b/swaybar/bar.c
index ebb9bc12..4fd9c488 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -124,7 +124,7 @@ static void destroy_layer_surface(struct swaybar_output *output) {
output->frame_scheduled = false;
}
-static void set_bar_dirty(struct swaybar *bar) {
+void set_bar_dirty(struct swaybar *bar) {
struct swaybar_output *output;
wl_list_for_each(output, &bar->outputs, link) {
set_output_dirty(output);
diff --git a/swaybar/tray/host.c b/swaybar/tray/host.c
index 8ab896d4..c5756f17 100644
--- a/swaybar/tray/host.c
+++ b/swaybar/tray/host.c
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "swaybar/bar.h"
#include "swaybar/tray/host.h"
#include "swaybar/tray/item.h"
#include "swaybar/tray/tray.h"
@@ -56,6 +57,7 @@ static int handle_sni_unregistered(sd_bus_message *msg, void *data,
wlr_log(WLR_DEBUG, "Unregistering Status Notifier Item '%s'", id);
destroy_sni(tray->items->items[idx]);
list_del(tray->items, idx);
+ set_bar_dirty(tray->bar);
}
return ret;
}
diff --git a/swaybar/tray/item.c b/swaybar/tray/item.c
index 450b6882..98d3dc1f 100644
--- a/swaybar/tray/item.c
+++ b/swaybar/tray/item.c
@@ -24,6 +24,13 @@ static bool sni_ready(struct swaybar_sni *sni) {
sni->icon_name || sni->icon_pixmap);
}
+static void set_sni_dirty(struct swaybar_sni *sni) {
+ if (sni_ready(sni)) {
+ sni->min_size = sni->max_size = 0; // invalidate previous icon
+ set_bar_dirty(sni->tray->bar);
+ }
+}
+
static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
const char *prop, list_t **dest) {
int ret = sd_bus_message_enter_container(msg, 'a', "(iiay)");
@@ -124,6 +131,11 @@ static int get_property_callback(sd_bus_message *msg, void *data,
*str = strdup(*str);
}
}
+
+ if (strcmp(prop, "Status") == 0 || (sni->status && (sni->status[0] == 'N' ?
+ prop[0] == 'A' : strncmp(prop, "Icon", 4) == 0))) {
+ set_sni_dirty(sni);
+ }
cleanup:
free(data);
return ret;
@@ -185,6 +197,7 @@ static int handle_new_status(sd_bus_message *msg, void *data, sd_bus_error *erro
free(sni->status);
sni->status = strdup(status);
wlr_log(WLR_DEBUG, "%s has new Status '%s'", sni->watcher_id, status);
+ set_sni_dirty(sni);
}
return ret;
}