23 lines
733 B
Common Lisp
Executable file
23 lines
733 B
Common Lisp
Executable file
#!/usr/bin/env -S sbcl --script
|
|
(require "uiop")
|
|
(load "/home/chris/.sbclrc")
|
|
(ql:quickload :clingon)
|
|
(defun get-value (file)
|
|
"Read a file and get it's value as a list of lines"
|
|
(with-open-file (in file)
|
|
(loop for line = (read-line in nil nil)
|
|
while line
|
|
collect line)))
|
|
|
|
(setf capacity (parse-integer (car (get-value "/sys/class/sound/card0/number"))))
|
|
(setf status (parse-integer (car (get-value "/sys/class/sound/card1/number"))))
|
|
|
|
(loop for i from 0
|
|
while (< i 10)
|
|
do (uiop:println i))
|
|
|
|
(if (<= capacity 30)
|
|
(uiop:run-program (uiop:strcat "/run/current-system/sw/bin/eww " "open " "battery"))
|
|
(uiop:run-program (uiop:strcat "/run/current-system/sw/bin/eww " "close " "battery")))
|
|
|