stumpwm/brightness.lisp @ 30faa48af4ce default tip

More
author Steve Losh <steve@stevelosh.com>
date Mon, 19 Aug 2024 08:56:24 -0400
parents 4673e928c08e
children (none)
(in-package :stumpwm-user)

(defparameter *brightness-values* #(0 1 5 10 20 30 40 55 70 85 100))
(defvar *brightness-index* 5)

(defun brightness ()
  (aref *brightness-values* *brightness-index*))

(defun set-brightness (value)
  (run-and-echo-shell-command
    (hostcase
      ((:gro :juss) (format nil "xrandr --output ~A --brightness ~D"
                      (hostcase ((:gro :juss) "eDP"))
                      (/ value 100.0)))
      (t (message "Not sure how to set brightness on this machine.")))))

(defun rotate-brightness (delta)
  (setf *brightness-index*
        (mod+ *brightness-index* delta (length *brightness-values*)))
  (set-brightness (brightness)))


(defcommand rotate-brightness-up () ()
  (rotate-brightness 1))

(defcommand rotate-brightness-down () ()
  (rotate-brightness -1))