diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2019-07-17 19:48:28 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-07-17 21:25:09 -0400 |
commit | 92b22ee9ea41ab236aae8d331781400ae2528995 (patch) | |
tree | 082390eef7ae9e0ecb930381b301e3ac47d65e27 /sway/commands | |
parent | input_cmd_xkb_*: cleanup includes (diff) | |
download | sway-92b22ee9ea41ab236aae8d331781400ae2528995.tar.gz sway-92b22ee9ea41ab236aae8d331781400ae2528995.tar.zst sway-92b22ee9ea41ab236aae8d331781400ae2528995.zip |
cmd_output: support current output alias
Similar to seat command, this provides an alias for the current output.
Instead of the output name or identifier, `-` can be used to operate on
the focused output by name and `--` can be used to operate on the
focused output by its identifier. This will prevent operating on the
no-op output when using either alias.
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/output.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/sway/commands/output.c b/sway/commands/output.c index 3903f10d..59bc598c 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c | |||
@@ -36,7 +36,32 @@ struct cmd_results *cmd_output(int argc, char **argv) { | |||
36 | "Refusing to configure the no op output"); | 36 | "Refusing to configure the no op output"); |
37 | } | 37 | } |
38 | 38 | ||
39 | struct output_config *output = new_output_config(argv[0]); | 39 | struct output_config *output = NULL; |
40 | if (strcmp(argv[0], "-") == 0 || strcmp(argv[0], "--") == 0) { | ||
41 | if (config->reading) { | ||
42 | return cmd_results_new(CMD_FAILURE, | ||
43 | "Current output alias (%s) cannot be used in the config", | ||
44 | argv[0]); | ||
45 | } | ||
46 | struct sway_output *sway_output = config->handler_context.node ? | ||
47 | node_get_output(config->handler_context.node) : NULL; | ||
48 | if (!sway_output) { | ||
49 | return cmd_results_new(CMD_FAILURE, "Unknown output"); | ||
50 | } | ||
51 | if (sway_output == root->noop_output) { | ||
52 | return cmd_results_new(CMD_FAILURE, | ||
53 | "Refusing to configure the no op output"); | ||
54 | } | ||
55 | if (strcmp(argv[0], "-") == 0) { | ||
56 | output = new_output_config(sway_output->wlr_output->name); | ||
57 | } else { | ||
58 | char identifier[128]; | ||
59 | output_get_identifier(identifier, 128, sway_output); | ||
60 | output = new_output_config(identifier); | ||
61 | } | ||
62 | } else { | ||
63 | output = new_output_config(argv[0]); | ||
64 | } | ||
40 | if (!output) { | 65 | if (!output) { |
41 | sway_log(SWAY_ERROR, "Failed to allocate output config"); | 66 | sway_log(SWAY_ERROR, "Failed to allocate output config"); |
42 | return NULL; | 67 | return NULL; |