diff --git a/main.c b/main.c index 5057da06..605326c2 100644 --- a/main.c +++ b/main.c @@ -1020,6 +1020,19 @@ static char *get_config_path(void) { return NULL; } +static void trim_end(char *str) { + if (strlen(str) == 0) { + return; + } + + char* end = str + strlen(str) - 1; + while (end > str && isspace((unsigned char)*end)) { + end--; + } + + *(end + 1) = '\0'; +} + static int load_config(char *path, struct swaylock_state *state, enum line_mode *line_mode) { FILE *config = fopen(path, "r"); @@ -1043,6 +1056,8 @@ static int load_config(char *path, struct swaylock_state *state, continue; } + trim_end(line); + swaylock_log(LOG_DEBUG, "Config Line #%d: %s", line_number, line); char *flag = malloc(nread + 3); if (flag == NULL) {