aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorfrsfnrrg <frsfnrrg@users.noreply.github.com>2018-05-27 12:37:18 -0400
committerfrsfnrrg <frsfnrrg@users.noreply.github.com>2018-05-27 13:28:02 -0400
commita78a5684ea8a19e54d797ab6cddd2f81f88360a5 (patch)
tree8870a8acc8d92d10d64e9d3d9bfdd28dedb6eea7 /sway/commands
parent0743b21cc89141c6783210a1f20b6b372b24ae59 (diff)
Implement bindsym/bindcode --locked
Adds the --locked flag to bindsym and bindcode commands. When a keyboard's associated seat has an exclusive client (i.e, a screenlocker), then bindings are only executed if they have the locked flag. When there is no such client, this restriction is lifted.
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/bind.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index cbabb07b..c6b3368a 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -83,20 +83,26 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) {
binding->keys = create_list();
binding->modifiers = 0;
binding->release = false;
+ binding->locked = false;
binding->bindcode = false;
- // Handle --release
- if (strcmp("--release", argv[0]) == 0) {
- if (argc >= 3) {
+ // Handle --release and --locked
+ while (argc > 0) {
+ if (strcmp("--release", argv[0]) == 0) {
binding->release = true;
- argv++;
- argc--;
+ } else if (strcmp("--locked", argv[0]) == 0) {
+ binding->locked = true;
} else {
- free_sway_binding(binding);
- return cmd_results_new(CMD_FAILURE, "bindsym",
- "Invalid bindsym command "
- "(expected more than 2 arguments, got %d)", argc);
+ break;
}
+ argv++;
+ argc--;
+ }
+ if (argc < 2) {
+ free_sway_binding(binding);
+ return cmd_results_new(CMD_FAILURE, "bindsym",
+ "Invalid bindsym command "
+ "(expected at least 2 non-option arguments, got %d)", argc);
}
binding->command = join_args(argv + 1, argc - 1);
@@ -176,20 +182,26 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) {
binding->keys = create_list();
binding->modifiers = 0;
binding->release = false;
+ binding->locked = false;
binding->bindcode = true;
- // Handle --release
- if (strcmp("--release", argv[0]) == 0) {
- if (argc >= 3) {
+ // Handle --release and --locked
+ while (argc > 0) {
+ if (strcmp("--release", argv[0]) == 0) {
binding->release = true;
- argv++;
- argc--;
+ } else if (strcmp("--locked", argv[0]) == 0) {
+ binding->locked = true;
} else {
- free_sway_binding(binding);
- return cmd_results_new(CMD_FAILURE, "bindcode",
- "Invalid bindcode command "
- "(expected more than 2 arguments, got %d)", argc);
+ break;
}
+ argv++;
+ argc--;
+ }
+ if (argc < 2) {
+ free_sway_binding(binding);
+ return cmd_results_new(CMD_FAILURE, "bindcode",
+ "Invalid bindcode command "
+ "(expected at least 2 non-option arguments, got %d)", argc);
}
binding->command = join_args(argv + 1, argc - 1);