adding battery scripts

This commit is contained in:
Chris Cochrun 2023-12-09 06:40:11 -06:00
parent 2d22c3d19c
commit ef33b07d6a
2 changed files with 29 additions and 0 deletions

7
scripts/batmon.el Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env -S emacs -Q --script
(let ((i 0))
(while (< i 10)
(message (int-to-string i))
(setq i (+ i 1))))
(shell-command (concat "eww " "open " "battery"))

22
scripts/batmon.lisp Executable file
View file

@ -0,0 +1,22 @@
#!/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")))