aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/ipc-client.c16
-rw-r--r--sway/config/output.c7
-rw-r--r--swaynag/config.c2
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) {
size_t line_size = 0;
FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r");
if (fp) {
- getline(&line, &line_size, fp);
+ ssize_t nret = getline(&line, &line_size, fp);
pclose(fp);
- if (line && *line) {
+ if (nret > 0) {
+ // remove trailing newline, if there is one
+ if (line[nret - 1] == '\n') {
+ line[nret - 1] = '\0';
+ }
return line;
}
}
@@ -35,9 +39,13 @@ char *get_socketpath(void) {
}
fp = popen("i3 --get-socketpath 2>/dev/null", "r");
if (fp) {
- getline(&line, &line_size, fp);
+ ssize_t nret = getline(&line, &line_size, fp);
pclose(fp);
- if (line && *line) {
+ if (nret > 0) {
+ // remove trailing newline, if there is one
+ if (line[nret - 1] == '\n') {
+ line[nret - 1] = '\0';
+ }
return line;
}
}
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) {
wlr_output_layout_add_auto(root->output_layout, wlr_output);
}
- int output_i;
- for (output_i = 0; output_i < root->outputs->length; ++output_i) {
- if (root->outputs->items[output_i] == output) {
- break;
- }
- }
-
if (output->bg_pid != 0) {
terminate_swaybg(output->bg_pid);
}
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) {
};
char *config_home = getenv("XDG_CONFIG_HOME");
- if (!config_home || *config_home) {
+ if (!config_home || config_home[0] == '\0') {
config_paths[1] = "$HOME/.config/swaynag/config";
}