diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-05-13 10:11:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-13 10:11:10 -0400 |
commit | 61aa0937a75d23c0f2a00a8cea52c08bf69164dd (patch) | |
tree | 5f2e7817313b657431870862d4059b62bcd2e396 /sway/commands | |
parent | 0c96d757d0d5d1762390dd119cbe344e8781c19f (diff) | |
parent | f40049b5cd8d0274a62399cbdd1f8fd0e7668be3 (diff) | |
download | sway-61aa0937a75d23c0f2a00a8cea52c08bf69164dd.tar.xz |
Merge pull request #1824 from snaggen/idle
DPMS and lock handling
Diffstat (limited to 'sway/commands')
-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[] = { "tile", }; +static struct cmd_results *cmd_output_dpms(struct output_config *output, + int *i, int argc, char **argv) { + + if (++*i >= argc) { + return cmd_results_new(CMD_INVALID, "output", "Missing dpms argument."); + } + + char *value = argv[*i]; + if (strcmp(value, "on") == 0) { + output->dpms_state = DPMS_ON; + } else if (strcmp(value, "off") == 0) { + output->dpms_state = DPMS_OFF; + } else { + return cmd_results_new(CMD_INVALID, "output", + "Invalid dpms state, valid states are on/off."); + } + return NULL; +} + static struct cmd_results *cmd_output_mode(struct output_config *output, int *i, int argc, char **argv) { if (++*i >= argc) { @@ -263,6 +282,8 @@ struct cmd_results *cmd_output(int argc, char **argv) { } else if (strcasecmp(command, "background") == 0 || strcasecmp(command, "bg") == 0) { error = cmd_output_background(output, &i, argc, argv); + } else if (strcasecmp(command, "dpms") == 0) { + error = cmd_output_dpms(output, &i, argc, argv); } else { error = cmd_results_new(CMD_INVALID, "output", "Invalid output subcommand: %s.", command); @@ -285,10 +306,10 @@ struct cmd_results *cmd_output(int argc, char **argv) { } wlr_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " - "position %d,%d scale %f transform %d) (bg %s %s)", + "position %d,%d scale %f transform %d) (bg %s %s) (dpms %d)", output->name, output->enabled, output->width, output->height, output->refresh_rate, output->x, output->y, output->scale, - output->transform, output->background, output->background_option); + output->transform, output->background, output->background_option, output->dpms_state); // Try to find the output container and apply configuration now. If // this is during startup then there will be no container and config |