adding battery scripts
This commit is contained in:
parent
2d22c3d19c
commit
ef33b07d6a
7
scripts/batmon.el
Executable file
7
scripts/batmon.el
Executable 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
22
scripts/batmon.lisp
Executable 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")))
|
||||||
|
|
Loading…
Reference in a new issue