2018-03-29 23:20:03 +02:00
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
#include <string.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include "sway/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;
|
|
|
|
}
|
2018-10-19 19:11:21 +02:00
|
|
|
char *valid[] = { "top", "bottom" };
|
2018-03-29 23:20:03 +02:00
|
|
|
for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
|
|
|
|
if (strcasecmp(valid[i], argv[0]) == 0) {
|
2019-01-20 19:51:12 +01:00
|
|
|
sway_log(SWAY_DEBUG, "Setting bar position '%s' for bar: %s",
|
2018-03-29 23:20:03 +02:00
|
|
|
argv[0], config->current_bar->id);
|
2018-07-15 22:47:22 +02:00
|
|
|
free(config->current_bar->position);
|
2018-03-29 23:20:03 +02:00
|
|
|
config->current_bar->position = strdup(argv[0]);
|
2019-01-11 00:27:21 +01:00
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
2018-03-29 23:20:03 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-11 00:27:21 +01:00
|
|
|
return cmd_results_new(CMD_INVALID, "Invalid value %s", argv[0]);
|
2018-03-29 23:20:03 +02:00
|
|
|
}
|