diff options
author | Timo Wilken | 2023-09-11 19:47:40 +0200 |
---|---|---|
committer | Timo Wilken | 2023-09-11 19:47:40 +0200 |
commit | 6135934e4594c7d46377a204d1c6bd3452b3edb5 (patch) | |
tree | 585f49dac28a46f1521e18846a10bb26468d20ab | |
parent | d6cb24e6b323639ab45b2b80ed53e39d7609574b (diff) |
Wait for backlight to come up before setting it
-rw-r--r-- | tw/system/lap.scm | 12 |
1 files changed, 9 insertions, 3 deletions
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 |