|
|
|
@ -32,7 +32,7 @@ static struct modifier_key modifiers[] = {
|
|
|
|
|
enum expected_args {
|
|
|
|
|
EXPECTED_MORE_THAN,
|
|
|
|
|
EXPECTED_LESS_THAN,
|
|
|
|
|
EXPECTED_SAME_AS
|
|
|
|
|
EXPECTED_EQUAL_TO
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static bool checkarg(int argc, char *name, enum expected_args type, int val) {
|
|
|
|
@ -53,7 +53,7 @@ static bool checkarg(int argc, char *name, enum expected_args type, int val) {
|
|
|
|
|
"(expected less then %d argument%s, got %d",
|
|
|
|
|
name, val, (char*[2]){"s", ""}[argc==1], argc);
|
|
|
|
|
break;
|
|
|
|
|
case EXPECTED_SAME_AS:
|
|
|
|
|
case EXPECTED_EQUAL_TO:
|
|
|
|
|
if (argc == val) {
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
@ -144,7 +144,7 @@ static bool cmd_exec(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool cmd_exit(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
if (!checkarg(argc, "exit", EXPECTED_SAME_AS, 0)) {
|
|
|
|
|
if (!checkarg(argc, "exit", EXPECTED_EQUAL_TO, 0)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// TODO: Some kind of clean up is probably in order
|
|
|
|
@ -153,7 +153,7 @@ static bool cmd_exit(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool cmd_focus(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
if (!checkarg(argc, "focus", EXPECTED_SAME_AS, 1)) {
|
|
|
|
|
if (!checkarg(argc, "focus", EXPECTED_EQUAL_TO, 1)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (strcasecmp(argv[0], "left") == 0) {
|
|
|
|
@ -171,7 +171,7 @@ static bool cmd_focus(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
if (!checkarg(argc, "focus_follows_mouse", EXPECTED_SAME_AS, 1)) {
|
|
|
|
|
if (!checkarg(argc, "focus_follows_mouse", EXPECTED_EQUAL_TO, 1)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -204,7 +204,7 @@ static bool cmd_layout(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool cmd_reload(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
if (!checkarg(argc, "reload", EXPECTED_SAME_AS, 0)) {
|
|
|
|
|
if (!checkarg(argc, "reload", EXPECTED_EQUAL_TO, 0)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!load_config()) {
|
|
|
|
@ -215,7 +215,7 @@ static bool cmd_reload(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool cmd_set(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
if (!checkarg(argc, "set", EXPECTED_SAME_AS, 2)) {
|
|
|
|
|
if (!checkarg(argc, "set", EXPECTED_EQUAL_TO, 2)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
struct sway_variable *var = malloc(sizeof(struct sway_variable));
|
|
|
|
@ -231,7 +231,7 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay
|
|
|
|
|
char *name = layout == L_VERT ? "splitv":
|
|
|
|
|
layout == L_HORIZ ? "splith":
|
|
|
|
|
"split";
|
|
|
|
|
if (!checkarg(argc, name, EXPECTED_SAME_AS, 0)) {
|
|
|
|
|
if (!checkarg(argc, name, EXPECTED_EQUAL_TO, 0)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
swayc_t *focused = get_focused_container(&root_container);
|
|
|
|
@ -263,7 +263,7 @@ static bool cmd_splith(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool cmd_log_colors(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
if (!checkarg(argc, "log_colors", EXPECTED_SAME_AS, 1)) {
|
|
|
|
|
if (!checkarg(argc, "log_colors", EXPECTED_EQUAL_TO, 1)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (strcasecmp(argv[0], "no") != 0 && strcasecmp(argv[0], "yes") != 0) {
|
|
|
|
@ -276,7 +276,7 @@ static bool cmd_log_colors(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
if (!checkarg(argc, "fullscreen", EXPECTED_SAME_AS, 0)) {
|
|
|
|
|
if (!checkarg(argc, "fullscreen", EXPECTED_EQUAL_TO, 0)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -289,7 +289,7 @@ static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool cmd_workspace(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
if (!checkarg(argc, "workspace", EXPECTED_SAME_AS, 1)) {
|
|
|
|
|
if (!checkarg(argc, "workspace", EXPECTED_EQUAL_TO, 1)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|