From c47f7668df883a7a7b90bd543f56e40ceb3c6498 Mon Sep 17 00:00:00 2001 From: Igor Kolokolnikov Date: Sat, 26 Sep 2026 19:26:28 -0700 Subject: [PATCH] Turn off screen and backlight on state change only. --- slock.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/slock.c b/slock.c index 8941ba6..54cf492 100644 --- a/slock.c +++ b/slock.c @@ -734,7 +734,8 @@ readpw(struct arena *arena, { XRRScreenChangeNotifyEvent *rre; char buf[32], passwd[256], *inputhash; - int num, screen, running, failure, locked, oldc, i, passing, dson, tfd, xfd; + int num, screen, running, failure, locked, oldc, i, passing, + dson, dson_saved, tfd, xfd; unsigned int len, color; struct timeval tv; KeySym ksym; @@ -751,7 +752,9 @@ readpw(struct arena *arena, failure = 0; locked = 1; oldc = INIT; - dson = 1; + + dson = 1; + dson_saved = 1; xfd = ConnectionNumber(dpy); tfd = timerfd_create(CLOCK_REALTIME, 0); @@ -905,13 +908,16 @@ readpw(struct arena *arena, } } - if(dson) { - reset_keyboard_backlight(bl_state); - set_screen_on(dpy); - } else { - set_keyboard_backlight_off(bl_state); - set_screen_off(dpy); + if(dson_saved != dson) { + if(dson) { + reset_keyboard_backlight(bl_state); + set_screen_on(dpy); + } else { + set_keyboard_backlight_off(bl_state); + set_screen_off(dpy); + } } + dson_saved = dson; render_screen(arena, dpy, locks,