commit 5520ee8fdb438d3ed8102db29783ef3750e2ce1f Author: Z-Shang Date: Sat Mar 29 01:21:53 2014 -0500 first commit diff --git a/main.lisp b/main.lisp new file mode 100644 index 0000000..dbb76e3 --- /dev/null +++ b/main.lisp @@ -0,0 +1,24 @@ +(defpackage :cl-battery + (:use :cl) + (:export + show-bat + ) + ) + +(in-package #:cl-battery) + +(defun show-bat () +(let ((bat_stat (open #P"/sys/class/power_supply/BAT0/status")) + (bat_now (open #P"/sys/class/power_supply/BAT0/current_now")) + (bat_full (open #P"/sys/class/power_supply/BAT0/charge_full")) + (ac_online (open #P"/sys/class/power_supply/ADP0/online")) + ) + (format *standard-output* "~A ~$% ~A~%" (read-line bat_stat) (* (float (/ (read bat_now) (read bat_full))) 100) + (if (equal (read ac_online) 1) + "To Be Fully Charged" + "Left")) + (close bat_stat) + (close bat_now) + (close bat_full))) + +(sb-ext:save-lisp-and-die #P"bat" :toplevel #'cl-battery:show-bat :executable t)