aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/tray/watcher.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/tray/watcher.c')
-rw-r--r--swaybar/tray/watcher.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/swaybar/tray/watcher.c b/swaybar/tray/watcher.c
index 16afc27c..2458a8c2 100644
--- a/swaybar/tray/watcher.c
+++ b/swaybar/tray/watcher.c
@@ -6,6 +6,7 @@
6#include <string.h> 6#include <string.h>
7#include "list.h" 7#include "list.h"
8#include "log.h" 8#include "log.h"
9#include "stringop.h"
9#include "swaybar/tray/watcher.h" 10#include "swaybar/tray/watcher.h"
10 11
11static const char *obj_path = "/StatusNotifierWatcher"; 12static const char *obj_path = "/StatusNotifierWatcher";
@@ -76,9 +77,7 @@ static int register_sni(sd_bus_message *msg, void *data, sd_bus_error *error) {
76 service = service_or_path; 77 service = service_or_path;
77 path = "/StatusNotifierItem"; 78 path = "/StatusNotifierItem";
78 } 79 }
79 size_t id_len = snprintf(NULL, 0, "%s%s", service, path) + 1; 80 id = format_str("%s%s", service, path);
80 id = malloc(id_len);
81 snprintf(id, id_len, "%s%s", service, path);
82 } 81 }
83 82
84 if (list_seq_find(watcher->items, cmp_id, id) == -1) { 83 if (list_seq_find(watcher->items, cmp_id, id) == -1) {
@@ -107,7 +106,7 @@ static int register_host(sd_bus_message *msg, void *data, sd_bus_error *error) {
107 sway_log(SWAY_DEBUG, "Registering Status Notifier Host '%s'", service); 106 sway_log(SWAY_DEBUG, "Registering Status Notifier Host '%s'", service);
108 list_add(watcher->hosts, strdup(service)); 107 list_add(watcher->hosts, strdup(service));
109 sd_bus_emit_signal(watcher->bus, obj_path, watcher->interface, 108 sd_bus_emit_signal(watcher->bus, obj_path, watcher->interface,
110 "StatusNotifierHostRegistered", "s", service); 109 "StatusNotifierHostRegistered", "");
111 } else { 110 } else {
112 sway_log(SWAY_DEBUG, "Status Notifier Host '%s' already registered", service); 111 sway_log(SWAY_DEBUG, "Status Notifier Host '%s' already registered", service);
113 } 112 }
@@ -159,9 +158,7 @@ struct swaybar_watcher *create_watcher(char *protocol, sd_bus *bus) {
159 return NULL; 158 return NULL;
160 } 159 }
161 160
162 size_t len = snprintf(NULL, 0, "org.%s.StatusNotifierWatcher", protocol) + 1; 161 watcher->interface = format_str("org.%s.StatusNotifierWatcher", protocol);
163 watcher->interface = malloc(len);
164 snprintf(watcher->interface, len, "org.%s.StatusNotifierWatcher", protocol);
165 162
166 sd_bus_slot *signal_slot = NULL, *vtable_slot = NULL; 163 sd_bus_slot *signal_slot = NULL, *vtable_slot = NULL;
167 int ret = sd_bus_add_object_vtable(bus, &vtable_slot, obj_path, 164 int ret = sd_bus_add_object_vtable(bus, &vtable_slot, obj_path,