mirror of
https://github.com/swaywm/sway.git
synced 2025-11-09 13:29:49 -05:00
Restrict CapsLock and NumLock commands to the configuration file
This commit is contained in:
parent
d07463d53b
commit
0ba52458ab
2 changed files with 24 additions and 7 deletions
|
|
@ -24,15 +24,19 @@ static struct cmd_handler input_handlers[] = {
|
|||
{ "scroll_method", input_cmd_scroll_method },
|
||||
{ "tap", input_cmd_tap },
|
||||
{ "tap_button_map", input_cmd_tap_button_map },
|
||||
{ "xkb_capslock", input_cmd_xkb_capslock },
|
||||
{ "xkb_layout", input_cmd_xkb_layout },
|
||||
{ "xkb_model", input_cmd_xkb_model },
|
||||
{ "xkb_numlock", input_cmd_xkb_numlock },
|
||||
{ "xkb_options", input_cmd_xkb_options },
|
||||
{ "xkb_rules", input_cmd_xkb_rules },
|
||||
{ "xkb_variant", input_cmd_xkb_variant },
|
||||
};
|
||||
|
||||
// must be in order for the bsearch
|
||||
static struct cmd_handler input_config_handlers[] = {
|
||||
{ "xkb_capslock", input_cmd_xkb_capslock },
|
||||
{ "xkb_numlock", input_cmd_xkb_numlock },
|
||||
};
|
||||
|
||||
struct cmd_results *cmd_input(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "input", EXPECTED_AT_LEAST, 2))) {
|
||||
|
|
@ -46,8 +50,21 @@ struct cmd_results *cmd_input(int argc, char **argv) {
|
|||
return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config");
|
||||
}
|
||||
|
||||
struct cmd_results *res = config_subcommand(argv + 1, argc - 1,
|
||||
struct cmd_results *res;
|
||||
|
||||
if (find_handler(argv[1], input_config_handlers,
|
||||
sizeof(input_config_handlers))) {
|
||||
if (config->reading) {
|
||||
res = config_subcommand(argv + 1, argc - 1,
|
||||
input_config_handlers, sizeof(input_config_handlers));
|
||||
} else {
|
||||
res = cmd_results_new(CMD_FAILURE, "input",
|
||||
"Can only be used in config file.");
|
||||
}
|
||||
} else {
|
||||
res = config_subcommand(argv + 1, argc - 1,
|
||||
input_handlers, sizeof(input_handlers));
|
||||
}
|
||||
|
||||
free_input_config(config->handler_context.input_config);
|
||||
config->handler_context.input_config = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue