aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/commands.h2
-rw-r--r--sway/commands/input.c2
-rw-r--r--sway/commands/input/xkb_capslock.c33
-rw-r--r--sway/commands/input/xkb_numlock.c33
-rw-r--r--sway/meson.build2
5 files changed, 72 insertions, 0 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index f53d335a..41858ccc 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -213,8 +213,10 @@ sway_cmd input_cmd_scroll_button;
213sway_cmd input_cmd_scroll_method; 213sway_cmd input_cmd_scroll_method;
214sway_cmd input_cmd_tap; 214sway_cmd input_cmd_tap;
215sway_cmd input_cmd_tap_button_map; 215sway_cmd input_cmd_tap_button_map;
216sway_cmd input_cmd_xkb_capslock;
216sway_cmd input_cmd_xkb_layout; 217sway_cmd input_cmd_xkb_layout;
217sway_cmd input_cmd_xkb_model; 218sway_cmd input_cmd_xkb_model;
219sway_cmd input_cmd_xkb_numlock;
218sway_cmd input_cmd_xkb_options; 220sway_cmd input_cmd_xkb_options;
219sway_cmd input_cmd_xkb_rules; 221sway_cmd input_cmd_xkb_rules;
220sway_cmd input_cmd_xkb_variant; 222sway_cmd input_cmd_xkb_variant;
diff --git a/sway/commands/input.c b/sway/commands/input.c
index 5b203ea0..7f927073 100644
--- a/sway/commands/input.c
+++ b/sway/commands/input.c
@@ -24,8 +24,10 @@ static struct cmd_handler input_handlers[] = {
24 { "scroll_method", input_cmd_scroll_method }, 24 { "scroll_method", input_cmd_scroll_method },
25 { "tap", input_cmd_tap }, 25 { "tap", input_cmd_tap },
26 { "tap_button_map", input_cmd_tap_button_map }, 26 { "tap_button_map", input_cmd_tap_button_map },
27 { "xkb_capslock", input_cmd_xkb_capslock },
27 { "xkb_layout", input_cmd_xkb_layout }, 28 { "xkb_layout", input_cmd_xkb_layout },
28 { "xkb_model", input_cmd_xkb_model }, 29 { "xkb_model", input_cmd_xkb_model },
30 { "xkb_numlock", input_cmd_xkb_numlock },
29 { "xkb_options", input_cmd_xkb_options }, 31 { "xkb_options", input_cmd_xkb_options },
30 { "xkb_rules", input_cmd_xkb_rules }, 32 { "xkb_rules", input_cmd_xkb_rules },
31 { "xkb_variant", input_cmd_xkb_variant }, 33 { "xkb_variant", input_cmd_xkb_variant },
diff --git a/sway/commands/input/xkb_capslock.c b/sway/commands/input/xkb_capslock.c
new file mode 100644
index 00000000..5442c463
--- /dev/null
+++ b/sway/commands/input/xkb_capslock.c
@@ -0,0 +1,33 @@
1#include <string.h>
2#include <strings.h>
3#include "sway/config.h"
4#include "sway/commands.h"
5#include "sway/input/input-manager.h"
6
7struct cmd_results *input_cmd_xkb_capslock(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "xkb_capslock", EXPECTED_AT_LEAST, 1))) {
10 return error;
11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
14 if (!current_input_config) {
15 return cmd_results_new(CMD_FAILURE, "xkb_capslock",
16 "No input device defined.");
17 }
18 struct input_config *new_config =
19 new_input_config(current_input_config->identifier);
20
21 if (strcasecmp(argv[0], "enabled") == 0) {
22 new_config->xkb_capslock = 1;
23 } else if (strcasecmp(argv[0], "disabled") == 0) {
24 new_config->xkb_capslock = 0;
25 } else {
26 free_input_config(new_config);
27 return cmd_results_new(CMD_INVALID, "xkb_capslock",
28 "Expected 'xkb_capslock <enabled|disabled>'");
29 }
30
31 apply_input_config(new_config);
32 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
33}
diff --git a/sway/commands/input/xkb_numlock.c b/sway/commands/input/xkb_numlock.c
new file mode 100644
index 00000000..39675366
--- /dev/null
+++ b/sway/commands/input/xkb_numlock.c
@@ -0,0 +1,33 @@
1#include <string.h>
2#include <strings.h>
3#include "sway/config.h"
4#include "sway/commands.h"
5#include "sway/input/input-manager.h"
6
7struct cmd_results *input_cmd_xkb_numlock(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "xkb_numlock", EXPECTED_AT_LEAST, 1))) {
10 return error;
11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
14 if (!current_input_config) {
15 return cmd_results_new(CMD_FAILURE, "xkb_numlock",
16 "No input device defined.");
17 }
18 struct input_config *new_config =
19 new_input_config(current_input_config->identifier);
20
21 if (strcasecmp(argv[0], "enabled") == 0) {
22 new_config->xkb_numlock = 1;
23 } else if (strcasecmp(argv[0], "disabled") == 0) {
24 new_config->xkb_numlock = 0;
25 } else {
26 free_input_config(new_config);
27 return cmd_results_new(CMD_INVALID, "xkb_numlock",
28 "Expected 'xkb_numlock <enabled|disabled>'");
29 }
30
31 apply_input_config(new_config);
32 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
33}
diff --git a/sway/meson.build b/sway/meson.build
index 649a3ac2..d92bb905 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -128,8 +128,10 @@ sway_sources = files(
128 'commands/input/scroll_method.c', 128 'commands/input/scroll_method.c',
129 'commands/input/tap.c', 129 'commands/input/tap.c',
130 'commands/input/tap_button_map.c', 130 'commands/input/tap_button_map.c',
131 'commands/input/xkb_capslock.c',
131 'commands/input/xkb_layout.c', 132 'commands/input/xkb_layout.c',
132 'commands/input/xkb_model.c', 133 'commands/input/xkb_model.c',
134 'commands/input/xkb_numlock.c',
133 'commands/input/xkb_options.c', 135 'commands/input/xkb_options.c',
134 'commands/input/xkb_rules.c', 136 'commands/input/xkb_rules.c',
135 'commands/input/xkb_variant.c', 137 'commands/input/xkb_variant.c',