aboutsummaryrefslogtreecommitdiff
path: root/src/light_thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/light_thread.c')
-rw-r--r--src/light_thread.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/light_thread.c b/src/light_thread.c
index 1d273a0..20b7bb9 100644
--- a/src/light_thread.c
+++ b/src/light_thread.c
@@ -2,14 +2,13 @@
#include <stdio.h>
-#include <stdint.h>
-#include <sys/time.h>
-
#include "common.h"
#include "consts.h"
#include "config.h"
#include "backlight.h"
+static pid_t keypress_pid;
+
uint64_t time_since_press(void) {
struct timeval now;
@@ -30,12 +29,24 @@ uint64_t time_since_press(void) {
return diff;
}
-int light_thread(void) {
- while (1) {
- if (time_since_press() > BACKLIGHT_TIME) backlight_off();
- else backlight_on();
+void handler(int _) {
+ if (time_since_press() > BACKLIGHT_TIME) {
+ backlight_off();
+ } else {
+ backlight_on();
- usleep(THREAD_WAIT);
+ handler(_);
+ }
+}
+
+int light_thread(pid_t _keypress_pid) {
+ keypress_pid = _keypress_pid;
+
+ signal(SIGCONT, handler);
+
+ while (1) {
+ pause();
+// usleep(THREAD_WAIT);
}
return 0;