diff options
Diffstat (limited to 'sway/commands/input/xkb_rules.c')
-rw-r--r-- | sway/commands/input/xkb_rules.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sway/commands/input/xkb_rules.c b/sway/commands/input/xkb_rules.c new file mode 100644 index 00000000..db7d8abe --- /dev/null +++ b/sway/commands/input/xkb_rules.c | |||
@@ -0,0 +1,25 @@ | |||
1 | #define _XOPEN_SOURCE 700 | ||
2 | #include "sway/config.h" | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/input/input-manager.h" | ||
5 | #include "log.h" | ||
6 | |||
7 | struct cmd_results *input_cmd_xkb_rules(int argc, char **argv) { | ||
8 | sway_log(L_DEBUG, "xkb rules for device: %s", current_input_config->identifier); | ||
9 | struct cmd_results *error = NULL; | ||
10 | if ((error = checkarg(argc, "xkb_rules", EXPECTED_EQUAL_TO, 1))) { | ||
11 | return error; | ||
12 | } | ||
13 | if (!current_input_config) { | ||
14 | return cmd_results_new(CMD_FAILURE, "xkb_rules", "No input device defined."); | ||
15 | } | ||
16 | struct input_config *new_config = | ||
17 | new_input_config(current_input_config->identifier); | ||
18 | |||
19 | new_config->xkb_rules = strdup(argv[0]); | ||
20 | |||
21 | sway_log(L_DEBUG, "apply-xkb_rules for device: %s rules: %s", | ||
22 | current_input_config->identifier, new_config->xkb_rules); | ||
23 | apply_input_config(new_config); | ||
24 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
25 | } | ||