From d71c11d9933bd7635b596672aed77993dd6b63b9 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Sat, 20 Feb 2021 13:23:18 +0100 Subject: [PATCH] Some improvements for the relock problem: Unable to open rtc device. But issue it not solved yet. #170 --- programs/sxmo_screenlock.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/programs/sxmo_screenlock.c b/programs/sxmo_screenlock.c index 0535a01..5153891 100644 --- a/programs/sxmo_screenlock.c +++ b/programs/sxmo_screenlock.c @@ -195,7 +195,10 @@ sigterm() { state = StateDead; syncstate(); - if (wakeinterval) close(rtc_fd); + if (wakeinterval) { + ioctl(rtc_fd, RTC_AIE_OFF, 0); + close(rtc_fd); + } fprintf(stderr, "Screenlock terminating on signal\n"); exit(0); } @@ -474,6 +477,7 @@ void usage() { void init_rtc() { rtc_fd = open(RTC_DEVICE, O_RDONLY); if (rtc_fd < 0) { + fprintf(stderr, "Error opening rtc device: %d\n", rtc_fd); die("Unable to open rtc device"); exit(EXIT_FAILURE); } @@ -522,6 +526,8 @@ main(int argc, char **argv) { if (!(dpy = XOpenDisplay(NULL))) die("Cannot open display"); + getoldbrightness(); + if (wakeinterval) init_rtc(); fprintf(stderr, "Screenlock starting\n"); @@ -529,7 +535,6 @@ main(int argc, char **argv) { XkbSetDetectableAutoRepeat(dpy, True, NULL); screen = XDefaultScreen(dpy); XSync(dpy, 0); - getoldbrightness(); syncstate(); lockscreen(dpy, screen, target == StateNoInputNoScreen || target == StateSuspend); if ((target == StateNoInputNoScreen) || (target == StateSuspend)) {