From 8fbafbfab5671d56dd469f2205b7906c4a7f7c7c Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Tue, 17 Apr 2018 09:54:02 +0200 Subject: 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 --- sway/config/output.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sway/config') diff --git a/sway/config/output.c b/sway/config/output.c index 68022278..ee2440ea 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -81,6 +81,9 @@ void merge_output_config(struct output_config *dst, struct output_config *src) { free(dst->background_option); dst->background_option = strdup(src->background_option); } + if (src->dpms_state != 0) { + dst->dpms_state = src->dpms_state; + } } static void set_mode(struct wlr_output *output, int width, int height, @@ -204,6 +207,20 @@ void apply_output_config(struct output_config *oc, struct sway_container *output execvp(cmd[0], cmd); } } + if (oc && oc->dpms_state != DPMS_IGNORE) { + switch (oc->dpms_state) { + case DPMS_ON: + wlr_log(L_DEBUG, "Turning on screen"); + wlr_output_enable(wlr_output, true); + break; + case DPMS_OFF: + wlr_log(L_DEBUG, "Turning off screen"); + wlr_output_enable(wlr_output, false); + break; + case DPMS_IGNORE: + break; + } + } } void free_output_config(struct output_config *oc) { -- cgit v1.2.3