diff options
author | Mattias Eriksson <snaggen@mayam.com> | 2018-04-17 09:54:02 +0200 |
---|---|---|
committer | Mattias Eriksson <snaggen@mayam.com> | 2018-05-13 00:30:09 +0200 |
commit | 8fbafbfab5671d56dd469f2205b7906c4a7f7c7c (patch) | |
tree | ab4eab0020d97dc5091b72479c383989ccc84729 /sway/commands/output.c | |
parent | Merge pull request #1967 from emersion/remove-xdg-popup-unmap (diff) | |
download | sway-8fbafbfab5671d56dd469f2205b7906c4a7f7c7c.tar.gz sway-8fbafbfab5671d56dd469f2205b7906c4a7f7c7c.tar.zst sway-8fbafbfab5671d56dd469f2205b7906c4a7f7c7c.zip |
Idle handling for dpms/lockscreen et al
Swayidle handles idle events and allows
for dpms and lockscreen handling. It also
handles systemd sleep events, and can
raise a lockscreen on sleep
Fixes #541
Diffstat (limited to 'sway/commands/output.c')
-rw-r--r-- | sway/commands/output.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/sway/commands/output.c b/sway/commands/output.c index f7e3372c..e8881f77 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c | |||
@@ -20,6 +20,25 @@ static char *bg_options[] = { | |||
20 | "tile", | 20 | "tile", |
21 | }; | 21 | }; |
22 | 22 | ||
23 | static struct cmd_results *cmd_output_dpms(struct output_config *output, | ||
24 | int *i, int argc, char **argv) { | ||
25 | |||
26 | if (++*i >= argc) { | ||
27 | return cmd_results_new(CMD_INVALID, "output", "Missing dpms argument."); | ||
28 | } | ||
29 | |||
30 | char *value = argv[*i]; | ||
31 | if (strcmp(value, "on") == 0) { | ||
32 | output->dpms_state = DPMS_ON; | ||
33 | } else if (strcmp(value, "off") == 0) { | ||
34 | output->dpms_state = DPMS_OFF; | ||
35 | } else { | ||
36 | return cmd_results_new(CMD_INVALID, "output", | ||
37 | "Invalid dpms state, valid states are on/off."); | ||
38 | } | ||
39 | return NULL; | ||
40 | } | ||
41 | |||
23 | static struct cmd_results *cmd_output_mode(struct output_config *output, | 42 | static struct cmd_results *cmd_output_mode(struct output_config *output, |
24 | int *i, int argc, char **argv) { | 43 | int *i, int argc, char **argv) { |
25 | if (++*i >= argc) { | 44 | if (++*i >= argc) { |
@@ -263,6 +282,8 @@ struct cmd_results *cmd_output(int argc, char **argv) { | |||
263 | } else if (strcasecmp(command, "background") == 0 || | 282 | } else if (strcasecmp(command, "background") == 0 || |
264 | strcasecmp(command, "bg") == 0) { | 283 | strcasecmp(command, "bg") == 0) { |
265 | error = cmd_output_background(output, &i, argc, argv); | 284 | error = cmd_output_background(output, &i, argc, argv); |
285 | } else if (strcasecmp(command, "dpms") == 0) { | ||
286 | error = cmd_output_dpms(output, &i, argc, argv); | ||
266 | } else { | 287 | } else { |
267 | error = cmd_results_new(CMD_INVALID, "output", | 288 | error = cmd_results_new(CMD_INVALID, "output", |
268 | "Invalid output subcommand: %s.", command); | 289 | "Invalid output subcommand: %s.", command); |
@@ -285,10 +306,10 @@ struct cmd_results *cmd_output(int argc, char **argv) { | |||
285 | } | 306 | } |
286 | 307 | ||
287 | wlr_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " | 308 | wlr_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " |
288 | "position %d,%d scale %f transform %d) (bg %s %s)", | 309 | "position %d,%d scale %f transform %d) (bg %s %s) (dpms %d)", |
289 | output->name, output->enabled, output->width, output->height, | 310 | output->name, output->enabled, output->width, output->height, |
290 | output->refresh_rate, output->x, output->y, output->scale, | 311 | output->refresh_rate, output->x, output->y, output->scale, |
291 | output->transform, output->background, output->background_option); | 312 | output->transform, output->background, output->background_option, output->dpms_state); |
292 | 313 | ||
293 | // Try to find the output container and apply configuration now. If | 314 | // Try to find the output container and apply configuration now. If |
294 | // this is during startup then there will be no container and config | 315 | // this is during startup then there will be no container and config |