Skip to content

Instantly share code, notes, and snippets.

@zarkone
Created November 1, 2017 02:44
Show Gist options
  • Save zarkone/cc48af24eec1f6824cd75c78535a7b5c to your computer and use it in GitHub Desktop.
Save zarkone/cc48af24eec1f6824cd75c78535a7b5c to your computer and use it in GitHub Desktop.
Backlight (brightness) control for stumpwm (using `sysfs`)
(defcommand set-backlight (level) ((:number "Set brightness level:"))
(with-open-file (sys-backlight-file "/sys/class/backlight/intel_backlight/brightness"
:direction :output :if-exists :overwrite)
(format sys-backlight-file "~a~%" (* 100 level))))
;; C-u [1-9] changes level
(defvar *brightness-map* nil)
(setf *brightness-map*
(let ((b (make-sparse-keymap)))
(loop for level from 1 below 10 by 1 do
(define-key b (kbd (write-to-string level))
(format nil "set-backlight ~a" level)))
b))
(define-key *root-map* (kbd "u") '*brightness-map*)
;; min and max level set with media keys
(define-key *top-map* (kbd "XF86MonBrightnessDown") "set-backlight 1")
(define-key *top-map* (kbd "XF86MonBrightnessUp") "set-backlight 9")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment