aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/bar/position.c
blob: 6f97062fa2c817d62e0005649390bdb5a7bb5d39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <string.h>
#include "commands.h"
#include "log.h"

struct cmd_results *bar_cmd_position(int argc, char **argv) {
	struct cmd_results *error = NULL;
	if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) {
		return error;
	}

	if (!config->current_bar) {
		return cmd_results_new(CMD_FAILURE, "position", "No bar defined.");
	}

	if (strcasecmp("top", argv[0]) == 0) {
		config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_TOP;
	} else if (strcasecmp("bottom", argv[0]) == 0) {
		config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
	} else if (strcasecmp("left", argv[0]) == 0) {
		sway_log(L_INFO, "Warning: swaybar currently only supports top and bottom positioning. YMMV");
		config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_LEFT;
	} else if (strcasecmp("right", argv[0]) == 0) {
		sway_log(L_INFO, "Warning: swaybar currently only supports top and bottom positioning. YMMV");
		config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_RIGHT;
	} else {
		error = cmd_results_new(CMD_INVALID, "position", "Invalid value %s", argv[0]);
		return error;
	}

	sway_log(L_DEBUG, "Setting bar position '%s' for bar: %s", argv[0], config->current_bar->id);
	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}