aboutsummaryrefslogtreecommitdiffstats
path: root/sway/swaynag.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/swaynag.c')
-rw-r--r--sway/swaynag.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/sway/swaynag.c b/sway/swaynag.c
index 4a0a6d30..bc5e23ea 100644
--- a/sway/swaynag.c
+++ b/sway/swaynag.c
@@ -1,4 +1,3 @@
1#define _POSIX_C_SOURCE 200809L
2#include <signal.h> 1#include <signal.h>
3#include <stdbool.h> 2#include <stdbool.h>
4#include <stdlib.h> 3#include <stdlib.h>
@@ -145,22 +144,16 @@ void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag,
145 144
146 va_list args; 145 va_list args;
147 va_start(args, fmt); 146 va_start(args, fmt);
148 size_t length = vsnprintf(NULL, 0, fmt, args) + 1; 147 char *str = vformat_str(fmt, args);
149 va_end(args); 148 va_end(args);
150 149 if (!str) {
151 char *temp = malloc(length + 1);
152 if (!temp) {
153 sway_log(SWAY_ERROR, "Failed to allocate buffer for swaynag log entry."); 150 sway_log(SWAY_ERROR, "Failed to allocate buffer for swaynag log entry.");
154 return; 151 return;
155 } 152 }
156 153
157 va_start(args, fmt); 154 write(swaynag->fd[1], str, strlen(str));
158 vsnprintf(temp, length, fmt, args);
159 va_end(args);
160
161 write(swaynag->fd[1], temp, length);
162 155
163 free(temp); 156 free(str);
164} 157}
165 158
166void swaynag_show(struct swaynag_instance *swaynag) { 159void swaynag_show(struct swaynag_instance *swaynag) {