From 6135934e4594c7d46377a204d1c6bd3452b3edb5 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Mon, 11 Sep 2023 19:47:40 +0200 Subject: Wait for backlight to come up before setting it --- tw/system/lap.scm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tw/system/lap.scm') diff --git a/tw/system/lap.scm b/tw/system/lap.scm index 0ca52a26..ab8f1dca 100644 --- a/tw/system/lap.scm +++ b/tw/system/lap.scm @@ -378,10 +378,16 @@ support extra features (acr, pmu, gr).") #~(begin (use-modules ((ice-9 textual-ports) #:select (get-string-all)) ((srfi srfi-26) #:select (cut))) + (define brightness-file "/sys/class/backlight/intel_backlight/brightness") + (define max-brightness-file "/sys/class/backlight/intel_backlight/max_brightness") + ;; These files don't exist right after startup, so wait for them to appear. + (while (not (and (file-exists? max-brightness-file) + (file-exists? brightness-file))) + (format (current-error-port) "Waiting for /sys files to appear...~%") + (sleep 1)) (define max-brightness - (call-with-input-file "/sys/class/backlight/intel_backlight/max_brightness" - get-string-all)) - (call-with-output-file "/sys/class/backlight/intel_backlight/brightness" + (call-with-input-file max-brightness-file get-string-all)) + (call-with-output-file brightness-file (cut display max-brightness <>)))))))))) (simple-service 'scanning-services shepherd-root-service-type -- cgit v1.2.3