diff options
Diffstat (limited to 'sway/commands/output.c')
-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; |