Created
September 8, 2017 12:35
-
-
Save dieggsy/a150c60c56f471464703e4a8a925bc0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/csi -s | |
(use dbus) | |
(: main (-> string)) | |
(define (main) | |
(let* ((kb-light (make-context | |
#:bus system-bus | |
#:service 'org.freedesktop.UPower | |
#:interface 'org.freedesktop.UPower.KbdBacklight | |
#:path '/org/freedesktop/UPower/KbdBacklight)) | |
(argv (command-line-arguments)) | |
(up-down (when (not (null? argv)) (car argv))) | |
(delta (cond ((equal? up-down "+") 17) | |
((equal? up-down "-") -17) | |
(else 0))) | |
(current (car (call kb-light "GetBrightness"))) | |
(maximum (car (call kb-light "GetMaxBrightness"))) | |
(new (max 0 (+ current delta)))) | |
(when (<= 0 new maximum) | |
(call kb-light "SetBrightness" new)) | |
(format #t "~s~%" (inexact->exact | |
(round (* 100 (/ new maximum))))))) | |
(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment