aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 322c9519..12d38244 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -8,6 +8,7 @@
#include <ctype.h>
#include "stringop.h"
#include "layout.h"
+#include "movement.h"
#include "log.h"
#include "commands.h"
@@ -97,6 +98,23 @@ int cmd_exit(struct sway_config *config, int argc, char **argv) {
return 0;
}
+int cmd_focus(struct sway_config *config, int argc, char **argv) {
+ if (argc != 1) {
+ sway_log(L_ERROR, "Invalid focus command (expected 1 arguments, got %d)", argc);
+ return 1;
+ }
+ if (strcasecmp(argv[0], "left") == 0) {
+ move_focus(MOVE_LEFT);
+ } else if (strcasecmp(argv[0], "right") == 0) {
+ move_focus(MOVE_RIGHT);
+ } else if (strcasecmp(argv[0], "up") == 0) {
+ move_focus(MOVE_UP);
+ } else if (strcasecmp(argv[0], "down") == 0) {
+ move_focus(MOVE_DOWN);
+ }
+ return 0;
+}
+
int cmd_focus_follows_mouse(struct sway_config *config, int argc, char **argv) {
if (argc != 1) {
sway_log(L_ERROR, "Invalid focus_follows_mouse command (expected 1 arguments, got %d)", argc);
@@ -184,6 +202,7 @@ struct cmd_handler handlers[] = {
{ "bindsym", cmd_bindsym },
{ "exec", cmd_exec },
{ "exit", cmd_exit },
+ { "focus", cmd_focus },
{ "focus_follows_mouse", cmd_focus_follows_mouse },
{ "layout", cmd_layout },
{ "set", cmd_set },