From f52825336ca32c7244ce08313d8a38afe5430aa5 Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Fri, 19 Oct 2018 08:30:05 +0200 Subject: [PATCH 1/2] swaybar: disallow left and right position and print error on default The positions "left" and "right" are not allowed by the man page, remove them from the allowed positions. Also print an error to stderr if we default to the bottom position. Fixes #2878 --- swaybar/config.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/swaybar/config.c b/swaybar/config.c index eafb0b69..1293cdae 100644 --- a/swaybar/config.c +++ b/swaybar/config.c @@ -1,6 +1,7 @@ #define _XOPEN_SOURCE 500 #include #include +#include #include "swaybar/config.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" #include "stringop.h" @@ -9,17 +10,12 @@ uint32_t parse_position(const char *position) { uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; - uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | - ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; if (strcmp("top", position) == 0) { return ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | horiz; } else if (strcmp("bottom", position) == 0) { return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz; - } else if (strcmp("left", position) == 0) { - return ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | vert; - } else if (strcmp("right", position) == 0) { - return ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | vert; } else { + wlr_log(WLR_ERROR, "Invalid position: %s, defaulting to bottom", position); return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz; } } From 17fb3b6994a65a7286cd21f3c25294ce5c8cceed Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Fri, 19 Oct 2018 19:11:21 +0200 Subject: [PATCH 2/2] commands/bar: remove left and right from allowed positions "left" and "right" are not allowed positions for swaybar, remove them. --- sway/commands/bar/position.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/commands/bar/position.c b/sway/commands/bar/position.c index 44bb4ae3..2870f60f 100644 --- a/sway/commands/bar/position.c +++ b/sway/commands/bar/position.c @@ -12,7 +12,7 @@ struct cmd_results *bar_cmd_position(int argc, char **argv) { if (!config->current_bar) { return cmd_results_new(CMD_FAILURE, "position", "No bar defined."); } - char *valid[] = { "top", "bottom", "left", "right" }; + char *valid[] = { "top", "bottom" }; for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) { if (strcasecmp(valid[i], argv[0]) == 0) { wlr_log(WLR_DEBUG, "Setting bar position '%s' for bar: %s",