Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. (defun battery-level ()
  2. (string-to-number (shell-command-to-string "echo \"$(pmset -g ps | awk 'NR==2' | perl -pe 's/.*?(\\d+)%.*/\\1/')\"")))
  3.  
  4. (defvar battery-status-function 'battery-level)
  5.  
  6. (defun battery-indicator-string ()
  7. (let* ((bat (funcall battery-status-function))
  8. (index (cl-position-if (lambda (e) (> bat e)) '(87 75 62 50 37 25 12 7 -1)))
  9. (symbol (nth index '("█" "▇" "▆" "▅" "▄" "▃" "▂" "▁" "!")))
  10. (color (nth index (mapcar (lambda (c) (apply 'color-rgb-to-hex c)) (color-gradient '(.3 1 .2) '(1 .2 .1) 9)))))
  11. (propertize symbol 'face (list :foreground color :box (if (<= bat 7) color nil)))))
  12.  
  13.  
  14.  
  15. (mapcar (lambda (c) (apply 'color-rgb-to-hex c)) (color-gradient '(.4 .9 .2) '(1 .2 .1) 9))
  16. ("#75d330" "#84c12d" "#93af2b" "#a39e28" "#b28c26" "#c17a23" "#d16821" "#e0561e" "#ef441c")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement