aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2022-06-22 22:06:21 +0200
committerLibravatar Simon Zeni <simon@bl4ckb0ne.ca>2022-06-23 14:47:50 -0400
commit445bc2a943d905a0e5b1dc607a6797919c8cf341 (patch)
treef6a8da587e1a324d0f1ec2fa69eaa487c1184be5
parentRemove access to wlr_input_device union (diff)
downloadsway-445bc2a943d905a0e5b1dc607a6797919c8cf341.tar.gz
sway-445bc2a943d905a0e5b1dc607a6797919c8cf341.tar.zst
sway-445bc2a943d905a0e5b1dc607a6797919c8cf341.zip
Rename dpms output command to power
The "dpms" command refers to VESA Display Power Management Signaling, a deprecated standard. It's superseded by VESA DPM. Instead of tying out command name to a particular standard, use the neutral term "power".
-rw-r--r--include/sway/commands.h1
-rw-r--r--sway/commands/output.c1
-rw-r--r--sway/commands/output/dpms.c45
-rw-r--r--sway/commands/output/power.c43
-rw-r--r--sway/meson.build1
-rw-r--r--sway/sway-output.5.scd12
6 files changed, 60 insertions, 43 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 5f71a79d..013a7b82 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -287,6 +287,7 @@ sway_cmd output_cmd_max_render_time;
287sway_cmd output_cmd_mode; 287sway_cmd output_cmd_mode;
288sway_cmd output_cmd_modeline; 288sway_cmd output_cmd_modeline;
289sway_cmd output_cmd_position; 289sway_cmd output_cmd_position;
290sway_cmd output_cmd_power;
290sway_cmd output_cmd_render_bit_depth; 291sway_cmd output_cmd_render_bit_depth;
291sway_cmd output_cmd_scale; 292sway_cmd output_cmd_scale;
292sway_cmd output_cmd_scale_filter; 293sway_cmd output_cmd_scale_filter;
diff --git a/sway/commands/output.c b/sway/commands/output.c
index 125df5a7..c102344d 100644
--- a/sway/commands/output.c
+++ b/sway/commands/output.c
@@ -18,6 +18,7 @@ static const struct cmd_handler output_handlers[] = {
18 { "modeline", output_cmd_modeline }, 18 { "modeline", output_cmd_modeline },
19 { "pos", output_cmd_position }, 19 { "pos", output_cmd_position },
20 { "position", output_cmd_position }, 20 { "position", output_cmd_position },
21 { "power", output_cmd_power },
21 { "render_bit_depth", output_cmd_render_bit_depth }, 22 { "render_bit_depth", output_cmd_render_bit_depth },
22 { "res", output_cmd_mode }, 23 { "res", output_cmd_mode },
23 { "resolution", output_cmd_mode }, 24 { "resolution", output_cmd_mode },
diff --git a/sway/commands/output/dpms.c b/sway/commands/output/dpms.c
index 638c0ade..c7adbd58 100644
--- a/sway/commands/output/dpms.c
+++ b/sway/commands/output/dpms.c
@@ -1,45 +1,8 @@
1#include "log.h"
1#include "sway/commands.h" 2#include "sway/commands.h"
2#include "sway/config.h"
3#include "sway/output.h"
4#include "util.h"
5#include <strings.h>
6 3
7struct cmd_results *output_cmd_dpms(int argc, char **argv) { 4struct cmd_results *output_cmd_dpms(int argc, char **argv) {
8 if (!config->handler_context.output_config) { 5 sway_log(SWAY_INFO, "The \"output dpms\" command is deprecated, "
9 return cmd_results_new(CMD_FAILURE, "Missing output config"); 6 "use \"output power\" instead");
10 } 7 return output_cmd_power(argc, argv);
11 if (!argc) {
12 return cmd_results_new(CMD_INVALID, "Missing dpms argument.");
13 }
14
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)) {
37 config->handler_context.output_config->dpms_state = DPMS_ON;
38 } else {
39 config->handler_context.output_config->dpms_state = DPMS_OFF;
40 }
41
42 config->handler_context.leftovers.argc = argc - 1;
43 config->handler_context.leftovers.argv = argv + 1;
44 return NULL;
45} 8}
diff --git a/sway/commands/output/power.c b/sway/commands/output/power.c
new file mode 100644
index 00000000..c783e69b
--- /dev/null
+++ b/sway/commands/output/power.c
@@ -0,0 +1,43 @@
1#include <strings.h>
2#include "sway/commands.h"
3#include "sway/config.h"
4#include "sway/output.h"
5#include "util.h"
6
7struct cmd_results *output_cmd_power(int argc, char **argv) {
8 if (!config->handler_context.output_config) {
9 return cmd_results_new(CMD_FAILURE, "Missing output config");
10 }
11 if (argc == 0) {
12 return cmd_results_new(CMD_INVALID, "Missing power argument");
13 }
14
15 enum config_dpms current_dpms = DPMS_ON;
16 if (strcasecmp(argv[0], "toggle") == 0) {
17 const char *oc_name = config->handler_context.output_config->name;
18 if (strcmp(oc_name, "*") == 0) {
19 return cmd_results_new(CMD_INVALID,
20 "Cannot apply toggle to all outputs");
21 }
22
23 struct sway_output *sway_output = all_output_by_name_or_id(oc_name);
24 if (!sway_output || !sway_output->wlr_output) {
25 return cmd_results_new(CMD_FAILURE,
26 "Cannot apply toggle to unknown output %s", oc_name);
27 }
28
29 if (sway_output->enabled && !sway_output->wlr_output->enabled) {
30 current_dpms = DPMS_OFF;
31 }
32 }
33
34 if (parse_boolean(argv[0], current_dpms == DPMS_ON)) {
35 config->handler_context.output_config->dpms_state = DPMS_ON;
36 } else {
37 config->handler_context.output_config->dpms_state = DPMS_OFF;
38 }
39
40 config->handler_context.leftovers.argc = argc - 1;
41 config->handler_context.leftovers.argv = argv + 1;
42 return NULL;
43}
diff --git a/sway/meson.build b/sway/meson.build
index 47c59dd5..ced7419c 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -191,6 +191,7 @@ sway_sources = files(
191 'commands/output/max_render_time.c', 191 'commands/output/max_render_time.c',
192 'commands/output/mode.c', 192 'commands/output/mode.c',
193 'commands/output/position.c', 193 'commands/output/position.c',
194 'commands/output/power.c',
194 'commands/output/render_bit_depth.c', 195 'commands/output/render_bit_depth.c',
195 'commands/output/scale.c', 196 'commands/output/scale.c',
196 'commands/output/scale_filter.c', 197 'commands/output/scale_filter.c',
diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd
index 4159a851..45429da2 100644
--- a/sway/sway-output.5.scd
+++ b/sway/sway-output.5.scd
@@ -119,12 +119,20 @@ must be separated by one space. For example:
119 Enables or disables the specified output (all outputs are enabled by 119 Enables or disables the specified output (all outputs are enabled by
120 default). 120 default).
121 121
122 As opposed to the _power_ command, the output will loose its current
123 workspace and windows.
124
122*output* <name> toggle 125*output* <name> toggle
123 Toggle the specified output. 126 Toggle the specified output.
124 127
128*output* <name> power on|off|toggle
129 Turns on or off the specified output.
130
131 As opposed to the _enable_ and _disable_ commands, the output keeps its
132 current workspaces and windows.
133
125*output* <name> dpms on|off|toggle 134*output* <name> dpms on|off|toggle
126 Enables or disables the specified output via DPMS. To turn an output off 135 Deprecated. Alias for _power_.
127 (ie. blank the screen but keep workspaces as-is), one can set DPMS to off.
128 136
129*output* <name> max_render_time off|<msec> 137*output* <name> max_render_time off|<msec>
130 Controls when sway composites the output, as a positive number of 138 Controls when sway composites the output, as a positive number of