summaryrefslogtreecommitdiffstats
path: root/swaybar/tray/host.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/tray/host.c')
-rw-r--r--swaybar/tray/host.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/swaybar/tray/host.c b/swaybar/tray/host.c
index cc8dd188..215e1e72 100644
--- a/swaybar/tray/host.c
+++ b/swaybar/tray/host.c
@@ -21,7 +21,7 @@ static int cmp_sni_id(const void *item, const void *cmp_to) {
21static void add_sni(struct swaybar_tray *tray, char *id) { 21static void add_sni(struct swaybar_tray *tray, char *id) {
22 int idx = list_seq_find(tray->items, cmp_sni_id, id); 22 int idx = list_seq_find(tray->items, cmp_sni_id, id);
23 if (idx == -1) { 23 if (idx == -1) {
24 wlr_log(WLR_INFO, "Registering Status Notifier Item '%s'", id); 24 sway_log(SWAY_INFO, "Registering Status Notifier Item '%s'", id);
25 struct swaybar_sni *sni = create_sni(id, tray); 25 struct swaybar_sni *sni = create_sni(id, tray);
26 if (sni) { 26 if (sni) {
27 list_add(tray->items, sni); 27 list_add(tray->items, sni);
@@ -34,7 +34,7 @@ static int handle_sni_registered(sd_bus_message *msg, void *data,
34 char *id; 34 char *id;
35 int ret = sd_bus_message_read(msg, "s", &id); 35 int ret = sd_bus_message_read(msg, "s", &id);
36 if (ret < 0) { 36 if (ret < 0) {
37 wlr_log(WLR_ERROR, "Failed to parse register SNI message: %s", strerror(-ret)); 37 sway_log(SWAY_ERROR, "Failed to parse register SNI message: %s", strerror(-ret));
38 } 38 }
39 39
40 struct swaybar_tray *tray = data; 40 struct swaybar_tray *tray = data;
@@ -48,13 +48,13 @@ static int handle_sni_unregistered(sd_bus_message *msg, void *data,
48 char *id; 48 char *id;
49 int ret = sd_bus_message_read(msg, "s", &id); 49 int ret = sd_bus_message_read(msg, "s", &id);
50 if (ret < 0) { 50 if (ret < 0) {
51 wlr_log(WLR_ERROR, "Failed to parse unregister SNI message: %s", strerror(-ret)); 51 sway_log(SWAY_ERROR, "Failed to parse unregister SNI message: %s", strerror(-ret));
52 } 52 }
53 53
54 struct swaybar_tray *tray = data; 54 struct swaybar_tray *tray = data;
55 int idx = list_seq_find(tray->items, cmp_sni_id, id); 55 int idx = list_seq_find(tray->items, cmp_sni_id, id);
56 if (idx != -1) { 56 if (idx != -1) {
57 wlr_log(WLR_INFO, "Unregistering Status Notifier Item '%s'", id); 57 sway_log(SWAY_INFO, "Unregistering Status Notifier Item '%s'", id);
58 destroy_sni(tray->items->items[idx]); 58 destroy_sni(tray->items->items[idx]);
59 list_del(tray->items, idx); 59 list_del(tray->items, idx);
60 set_bar_dirty(tray->bar); 60 set_bar_dirty(tray->bar);
@@ -66,20 +66,20 @@ static int get_registered_snis_callback(sd_bus_message *msg, void *data,
66 sd_bus_error *error) { 66 sd_bus_error *error) {
67 if (sd_bus_message_is_method_error(msg, NULL)) { 67 if (sd_bus_message_is_method_error(msg, NULL)) {
68 sd_bus_error err = *sd_bus_message_get_error(msg); 68 sd_bus_error err = *sd_bus_message_get_error(msg);
69 wlr_log(WLR_ERROR, "Failed to get registered SNIs: %s", err.message); 69 sway_log(SWAY_ERROR, "Failed to get registered SNIs: %s", err.message);
70 return -sd_bus_error_get_errno(&err); 70 return -sd_bus_error_get_errno(&err);
71 } 71 }
72 72
73 int ret = sd_bus_message_enter_container(msg, 'v', NULL); 73 int ret = sd_bus_message_enter_container(msg, 'v', NULL);
74 if (ret < 0) { 74 if (ret < 0) {
75 wlr_log(WLR_ERROR, "Failed to read registered SNIs: %s", strerror(-ret)); 75 sway_log(SWAY_ERROR, "Failed to read registered SNIs: %s", strerror(-ret));
76 return ret; 76 return ret;
77 } 77 }
78 78
79 char **ids; 79 char **ids;
80 ret = sd_bus_message_read_strv(msg, &ids); 80 ret = sd_bus_message_read_strv(msg, &ids);
81 if (ret < 0) { 81 if (ret < 0) {
82 wlr_log(WLR_ERROR, "Failed to read registered SNIs: %s", strerror(-ret)); 82 sway_log(SWAY_ERROR, "Failed to read registered SNIs: %s", strerror(-ret));
83 return ret; 83 return ret;
84 } 84 }
85 85
@@ -99,7 +99,7 @@ static bool register_to_watcher(struct swaybar_host *host) {
99 host->watcher_interface, watcher_path, host->watcher_interface, 99 host->watcher_interface, watcher_path, host->watcher_interface,
100 "RegisterStatusNotifierHost", NULL, NULL, "s", host->service); 100 "RegisterStatusNotifierHost", NULL, NULL, "s", host->service);
101 if (ret < 0) { 101 if (ret < 0) {
102 wlr_log(WLR_ERROR, "Failed to send register call: %s", strerror(-ret)); 102 sway_log(SWAY_ERROR, "Failed to send register call: %s", strerror(-ret));
103 return false; 103 return false;
104 } 104 }
105 105
@@ -109,7 +109,7 @@ static bool register_to_watcher(struct swaybar_host *host) {
109 get_registered_snis_callback, host->tray, "ss", 109 get_registered_snis_callback, host->tray, "ss",
110 host->watcher_interface, "RegisteredStatusNotifierItems"); 110 host->watcher_interface, "RegisteredStatusNotifierItems");
111 if (ret < 0) { 111 if (ret < 0) {
112 wlr_log(WLR_ERROR, "Failed to get registered SNIs: %s", strerror(-ret)); 112 sway_log(SWAY_ERROR, "Failed to get registered SNIs: %s", strerror(-ret));
113 } 113 }
114 114
115 return ret >= 0; 115 return ret >= 0;
@@ -120,7 +120,7 @@ static int handle_new_watcher(sd_bus_message *msg,
120 char *service, *old_owner, *new_owner; 120 char *service, *old_owner, *new_owner;
121 int ret = sd_bus_message_read(msg, "sss", &service, &old_owner, &new_owner); 121 int ret = sd_bus_message_read(msg, "sss", &service, &old_owner, &new_owner);
122 if (ret < 0) { 122 if (ret < 0) {
123 wlr_log(WLR_ERROR, "Failed to parse owner change message: %s", strerror(-ret)); 123 sway_log(SWAY_ERROR, "Failed to parse owner change message: %s", strerror(-ret));
124 return ret; 124 return ret;
125 } 125 }
126 126
@@ -148,7 +148,7 @@ bool init_host(struct swaybar_host *host, char *protocol,
148 watcher_path, host->watcher_interface, 148 watcher_path, host->watcher_interface,
149 "StatusNotifierItemRegistered", handle_sni_registered, tray); 149 "StatusNotifierItemRegistered", handle_sni_registered, tray);
150 if (ret < 0) { 150 if (ret < 0) {
151 wlr_log(WLR_ERROR, "Failed to subscribe to registering events: %s", 151 sway_log(SWAY_ERROR, "Failed to subscribe to registering events: %s",
152 strerror(-ret)); 152 strerror(-ret));
153 goto error; 153 goto error;
154 } 154 }
@@ -156,7 +156,7 @@ bool init_host(struct swaybar_host *host, char *protocol,
156 watcher_path, host->watcher_interface, 156 watcher_path, host->watcher_interface,
157 "StatusNotifierItemUnregistered", handle_sni_unregistered, tray); 157 "StatusNotifierItemUnregistered", handle_sni_unregistered, tray);
158 if (ret < 0) { 158 if (ret < 0) {
159 wlr_log(WLR_ERROR, "Failed to subscribe to unregistering events: %s", 159 sway_log(SWAY_ERROR, "Failed to subscribe to unregistering events: %s",
160 strerror(-ret)); 160 strerror(-ret));
161 goto error; 161 goto error;
162 } 162 }
@@ -165,7 +165,7 @@ bool init_host(struct swaybar_host *host, char *protocol,
165 "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameOwnerChanged", 165 "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameOwnerChanged",
166 handle_new_watcher, host); 166 handle_new_watcher, host);
167 if (ret < 0) { 167 if (ret < 0) {
168 wlr_log(WLR_ERROR, "Failed to subscribe to unregistering events: %s", 168 sway_log(SWAY_ERROR, "Failed to subscribe to unregistering events: %s",
169 strerror(-ret)); 169 strerror(-ret));
170 goto error; 170 goto error;
171 } 171 }
@@ -180,7 +180,7 @@ bool init_host(struct swaybar_host *host, char *protocol,
180 snprintf(host->service, service_len, "org.%s.StatusNotifierHost-%d", protocol, pid); 180 snprintf(host->service, service_len, "org.%s.StatusNotifierHost-%d", protocol, pid);
181 ret = sd_bus_request_name(tray->bus, host->service, 0); 181 ret = sd_bus_request_name(tray->bus, host->service, 0);
182 if (ret < 0) { 182 if (ret < 0) {
183 wlr_log(WLR_DEBUG, "Failed to acquire service name: %s", strerror(-ret)); 183 sway_log(SWAY_DEBUG, "Failed to acquire service name: %s", strerror(-ret));
184 goto error; 184 goto error;
185 } 185 }
186 186
@@ -193,7 +193,7 @@ bool init_host(struct swaybar_host *host, char *protocol,
193 sd_bus_slot_set_floating(unreg_slot, 1); 193 sd_bus_slot_set_floating(unreg_slot, 1);
194 sd_bus_slot_set_floating(watcher_slot, 1); 194 sd_bus_slot_set_floating(watcher_slot, 1);
195 195
196 wlr_log(WLR_DEBUG, "Registered %s", host->service); 196 sway_log(SWAY_DEBUG, "Registered %s", host->service);
197 return true; 197 return true;
198error: 198error:
199 sd_bus_slot_unref(reg_slot); 199 sd_bus_slot_unref(reg_slot);