diff options
-rw-r--r-- | common/ipc-client.c | 16 | ||||
-rw-r--r-- | sway/config/output.c | 7 | ||||
-rw-r--r-- | swaynag/config.c | 2 |
3 files changed, 13 insertions, 12 deletions
diff --git a/common/ipc-client.c b/common/ipc-client.c index 1e88e71f..79ed3555 100644 --- a/common/ipc-client.c +++ b/common/ipc-client.c | |||
@@ -22,9 +22,13 @@ char *get_socketpath(void) { | |||
22 | size_t line_size = 0; | 22 | size_t line_size = 0; |
23 | FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r"); | 23 | FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r"); |
24 | if (fp) { | 24 | if (fp) { |
25 | getline(&line, &line_size, fp); | 25 | ssize_t nret = getline(&line, &line_size, fp); |
26 | pclose(fp); | 26 | pclose(fp); |
27 | if (line && *line) { | 27 | if (nret > 0) { |
28 | // remove trailing newline, if there is one | ||
29 | if (line[nret - 1] == '\n') { | ||
30 | line[nret - 1] = '\0'; | ||
31 | } | ||
28 | return line; | 32 | return line; |
29 | } | 33 | } |
30 | } | 34 | } |
@@ -35,9 +39,13 @@ char *get_socketpath(void) { | |||
35 | } | 39 | } |
36 | fp = popen("i3 --get-socketpath 2>/dev/null", "r"); | 40 | fp = popen("i3 --get-socketpath 2>/dev/null", "r"); |
37 | if (fp) { | 41 | if (fp) { |
38 | getline(&line, &line_size, fp); | 42 | ssize_t nret = getline(&line, &line_size, fp); |
39 | pclose(fp); | 43 | pclose(fp); |
40 | if (line && *line) { | 44 | if (nret > 0) { |
45 | // remove trailing newline, if there is one | ||
46 | if (line[nret - 1] == '\n') { | ||
47 | line[nret - 1] = '\0'; | ||
48 | } | ||
41 | return line; | 49 | return line; |
42 | } | 50 | } |
43 | } | 51 | } |
diff --git a/sway/config/output.c b/sway/config/output.c index 6e504751..8f59c863 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -234,13 +234,6 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { | |||
234 | wlr_output_layout_add_auto(root->output_layout, wlr_output); | 234 | wlr_output_layout_add_auto(root->output_layout, wlr_output); |
235 | } | 235 | } |
236 | 236 | ||
237 | int output_i; | ||
238 | for (output_i = 0; output_i < root->outputs->length; ++output_i) { | ||
239 | if (root->outputs->items[output_i] == output) { | ||
240 | break; | ||
241 | } | ||
242 | } | ||
243 | |||
244 | if (output->bg_pid != 0) { | 237 | if (output->bg_pid != 0) { |
245 | terminate_swaybg(output->bg_pid); | 238 | terminate_swaybg(output->bg_pid); |
246 | } | 239 | } |
diff --git a/swaynag/config.c b/swaynag/config.c index b4c22443..e5e940c7 100644 --- a/swaynag/config.c +++ b/swaynag/config.c | |||
@@ -305,7 +305,7 @@ char *swaynag_get_config_path(void) { | |||
305 | }; | 305 | }; |
306 | 306 | ||
307 | char *config_home = getenv("XDG_CONFIG_HOME"); | 307 | char *config_home = getenv("XDG_CONFIG_HOME"); |
308 | if (!config_home || *config_home) { | 308 | if (!config_home || config_home[0] == '\0') { |
309 | config_paths[1] = "$HOME/.config/swaynag/config"; | 309 | config_paths[1] = "$HOME/.config/swaynag/config"; |
310 | } | 310 | } |
311 | 311 | ||