From cf4cd1b8df00727104c3fdec3055aa890560bb18 Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Mon, 6 Jul 2020 20:10:12 -0500 Subject: [PATCH] Retain brightness when entering screenlock --- programs/sxmo_screenlock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/programs/sxmo_screenlock.c b/programs/sxmo_screenlock.c index e5ad677..04cbd3e 100644 --- a/programs/sxmo_screenlock.c +++ b/programs/sxmo_screenlock.c @@ -25,7 +25,7 @@ static Display *dpy; static enum State state = StateNoInput; static int lastkeysym = NULL; static int lastkeyn = 0; -static char * oldbrightness = "200"; +static char oldbrightness[10] = "200"; static char * brightnessfile = "/sys/devices/platform/backlight/backlight/backlight/brightness"; static char * powerstatefile = "/sys/power/state"; @@ -71,12 +71,12 @@ syncstate() syncstate(); } else if (state == StateNoInput) { setpineled(Blue); - writefile(brightnessfile, "200"); + writefile(brightnessfile, oldbrightness); } else if (state == StateNoInputNoScreen) { setpineled(Purple); writefile(brightnessfile, "0"); } else if (state == StateDead) { - writefile(brightnessfile, "200"); + writefile(brightnessfile, oldbrightness); setpineled(Off); } } @@ -171,7 +171,7 @@ getoldbrightness() { fclose(f); } if (buffer) { - oldbrightness = buffer; + sprintf(oldbrightness, "%d", atoi(buffer)); } }