aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/commands/output/dpms.c25
-rw-r--r--sway/sway-output.5.scd2
2 files changed, 25 insertions, 2 deletions
diff --git a/sway/commands/output/dpms.c b/sway/commands/output/dpms.c
index 9d75a80e..638c0ade 100644
--- a/sway/commands/output/dpms.c
+++ b/sway/commands/output/dpms.c
@@ -1,6 +1,8 @@
1#include "sway/commands.h" 1#include "sway/commands.h"
2#include "sway/config.h" 2#include "sway/config.h"
3#include "sway/output.h"
3#include "util.h" 4#include "util.h"
5#include <strings.h>
4 6
5struct cmd_results *output_cmd_dpms(int argc, char **argv) { 7struct cmd_results *output_cmd_dpms(int argc, char **argv) {
6 if (!config->handler_context.output_config) { 8 if (!config->handler_context.output_config) {
@@ -10,7 +12,28 @@ struct cmd_results *output_cmd_dpms(int argc, char **argv) {
10 return cmd_results_new(CMD_INVALID, "Missing dpms argument."); 12 return cmd_results_new(CMD_INVALID, "Missing dpms argument.");
11 } 13 }
12 14
13 if (parse_boolean(argv[0], true)) { 15 enum config_dpms current_dpms = DPMS_ON;
16
17 if (strcasecmp(argv[0], "toggle") == 0) {
18
19 const char *oc_name = config->handler_context.output_config->name;
20 if (strcmp(oc_name, "*") == 0) {
21 return cmd_results_new(CMD_INVALID,
22 "Cannot apply toggle to all outputs.");
23 }
24
25 struct sway_output *sway_output = all_output_by_name_or_id(oc_name);
26 if (!sway_output || !sway_output->wlr_output) {
27 return cmd_results_new(CMD_FAILURE,
28 "Cannot apply toggle to unknown output %s", oc_name);
29 }
30
31 if (sway_output->enabled && !sway_output->wlr_output->enabled) {
32 current_dpms = DPMS_OFF;
33 }
34 }
35
36 if (parse_boolean(argv[0], current_dpms == DPMS_ON)) {
14 config->handler_context.output_config->dpms_state = DPMS_ON; 37 config->handler_context.output_config->dpms_state = DPMS_ON;
15 } else { 38 } else {
16 config->handler_context.output_config->dpms_state = DPMS_OFF; 39 config->handler_context.output_config->dpms_state = DPMS_OFF;
diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd
index 69f529fe..7927a609 100644
--- a/sway/sway-output.5.scd
+++ b/sway/sway-output.5.scd
@@ -112,7 +112,7 @@ must be separated by one space. For example:
112*output* <name> toggle 112*output* <name> toggle
113 Toggle the specified output. 113 Toggle the specified output.
114 114
115*output* <name> dpms on|off 115*output* <name> dpms on|off|toggle
116 Enables or disables the specified output via DPMS. To turn an output off 116 Enables or disables the specified output via DPMS. To turn an output off
117 (ie. blank the screen but keep workspaces as-is), one can set DPMS to off. 117 (ie. blank the screen but keep workspaces as-is), one can set DPMS to off.
118 118