mirror of
https://github.com/swaywm/sway.git
synced 2024-11-24 08:51:27 +00:00
Toggle all outputs
This commit is contained in:
parent
0aceff7469
commit
e239a9aee9
|
@ -16,8 +16,14 @@ struct cmd_results *output_cmd_power(int argc, char **argv) {
|
||||||
if (strcasecmp(argv[0], "toggle") == 0) {
|
if (strcasecmp(argv[0], "toggle") == 0) {
|
||||||
const char *oc_name = config->handler_context.output_config->name;
|
const char *oc_name = config->handler_context.output_config->name;
|
||||||
if (strcmp(oc_name, "*") == 0) {
|
if (strcmp(oc_name, "*") == 0) {
|
||||||
return cmd_results_new(CMD_INVALID,
|
for (int i = 0; i < config->output_configs->length; i++) {
|
||||||
"Cannot apply toggle to all outputs");
|
struct output_config *oc = config->output_configs->items[i];
|
||||||
|
oc->power = !oc->power;
|
||||||
|
}
|
||||||
|
|
||||||
|
config->handler_context.leftovers.argc = argc - 1;
|
||||||
|
config->handler_context.leftovers.argv = argv + 1;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sway_output *sway_output = all_output_by_name_or_id(oc_name);
|
struct sway_output *sway_output = all_output_by_name_or_id(oc_name);
|
||||||
|
|
|
@ -7,13 +7,13 @@ struct cmd_results *output_cmd_toggle(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_FAILURE, "Missing output config");
|
return cmd_results_new(CMD_FAILURE, "Missing output config");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct output_config *oc = config->handler_context.output_config;
|
if (strcmp(config->handler_context.output_config->name, "*") == 0) {
|
||||||
|
for (int i = 0; i < config->output_configs->length; i++) {
|
||||||
if (strcmp(oc->name, "*") == 0) {
|
struct output_config *oc = config->output_configs->items[i];
|
||||||
return cmd_results_new(CMD_INVALID,
|
oc->enabled = !oc->enabled;
|
||||||
"Cannot apply toggle to all outputs.");
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
struct output_config *oc = config->handler_context.output_config;
|
||||||
struct sway_output *sway_output = all_output_by_name_or_id(oc->name);
|
struct sway_output *sway_output = all_output_by_name_or_id(oc->name);
|
||||||
|
|
||||||
if (sway_output == NULL) {
|
if (sway_output == NULL) {
|
||||||
|
@ -30,6 +30,8 @@ struct cmd_results *output_cmd_toggle(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
free(oc);
|
free(oc);
|
||||||
|
}
|
||||||
|
|
||||||
config->handler_context.leftovers.argc = argc;
|
config->handler_context.leftovers.argc = argc;
|
||||||
config->handler_context.leftovers.argv = argv;
|
config->handler_context.leftovers.argv = argv;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue