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