[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[STUMP] [PATCH] Add "reverse" option to bar-zone-color, modify battery.l
From: |
John Li |
Subject: |
[STUMP] [PATCH] Add "reverse" option to bar-zone-color, modify battery.lisp to use it. |
Date: |
Wed, 16 Jul 2008 08:57:57 -0400 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
---
This addition lets the battery percentage be colorized just like
CPU. With the "reverse" option, bar-zone-color with colorize lower
numbers with higher criticalness.
Note: I'm not sure why bar-zone-color ran concatenate on just a single
string.
contrib/battery.lisp | 3 ++-
mode-line.lisp | 20 ++++++++++----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/contrib/battery.lisp b/contrib/battery.lisp
index aff4180..7ead492 100644
--- a/contrib/battery.lisp
+++ b/contrib/battery.lisp
@@ -93,7 +93,8 @@
(declare (ignore ml))
(current-battery-charge)
(if *bat-state*
- (format nil "BAT: ~D%~A"
+ (format nil "BAT: ^[~A~D%^]~A"
+ (bar-zone-color *bat-remain* t)
*bat-remain*
(if *bat-remain-time*
(format nil " (~2,'0d:~2,'0d) ~A" (car *bat-remain-time*)
(cadr *bat-remain-time*) *bat-state*) "")) "no battery"))
diff --git a/mode-line.lisp b/mode-line.lisp
index 9f8e940..41ae8b1 100644
--- a/mode-line.lisp
+++ b/mode-line.lisp
@@ -178,16 +178,16 @@ timer.")
(defvar *bar-hi-color* "^B^3*")
(defvar *bar-crit-color* "^B^1*")
-(defun bar-zone-color (percent)
- (concatenate 'string
- (cond
- ((>= percent 90)
- *bar-crit-color*)
- ((>= percent 50)
- *bar-hi-color*)
- ((>= percent 20)
- *bar-med-color*)
- (t ""))))
+(defun bar-zone-color (percent &optional reverse)
+ (if reverse
+ (cond ((<= percent 10) *bar-crit-color*)
+ ((<= percent 50) *bar-hi-color*)
+ ((<= percent 80) *bar-med-color*)
+ (t ""))
+ (cond ((>= percent 90) *bar-crit-color*)
+ ((>= percent 50) *bar-hi-color*)
+ ((>= percent 20) *bar-med-color*)
+ (t ""))))
(defun repeat (n char)
(make-string n :initial-element char))
--
1.5.6
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [STUMP] [PATCH] Add "reverse" option to bar-zone-color, modify battery.lisp to use it.,
John Li <=