summaryrefslogtreecommitdiff
path: root/jakob.org
diff options
context:
space:
mode:
authorJakob L. Kreuze2019-09-14 17:41:08 -0400
committerJakob L. Kreuze2019-09-14 17:41:08 -0400
commitcde763e436a6c7af1dda3484daa73f4b27126abe (patch)
tree1d0ed3171b2a475ea42d63eea968ce784598a1a1 /jakob.org
parent5361066cb1c7b05d84e4314aa8f8b56155528952 (diff)
Update implementation of the modeline battery indicator.
Diffstat (limited to 'jakob.org')
-rw-r--r--jakob.org24
1 files changed, 9 insertions, 15 deletions
diff --git a/jakob.org b/jakob.org
index 30ac039..8b0b2a5 100644
--- a/jakob.org
+++ b/jakob.org
@@ -717,22 +717,16 @@ several minutes without being updated.
(force-mode-line-update))))
#+END_SRC
-My implementation of a battery monitor for the modeline. Because strings in
-=mode-line-format= can contain control sequences, the percent symbol has to be
-escaped twice -- once for =battery-format=, and once for =mode-line-format=.
+For some time, I was using my own implementation of a modeline battery monitor.
+However, the constant calls to =battery-linux-sysfs= were interfering with the way
+that EXWM handles input focus, and I've since moved towards reusing
+=display-battery-mode=. Because strings in =mode-line-format= can contain control
+sequences, the percent symbol has to be escaped twice -- once for
+=battery-format=, and once for =mode-line-format=.
#+BEGIN_SRC elisp
-(defun mode-line-battery-status ()
- (let* ((status (battery-linux-sysfs))
- (fullness (string-to-number (cdr (assoc 112 status))))
- (text (battery-format "%L: %t, %p%%%%" status))
- (low-battery-face '(:foreground "white"
- :background "red")))
- (when (< fullness 10.0)
- (put-text-property 0 (length text)
- 'font-lock-face low-battery-face
- text))
- text))
+(display-battery-mode +1)
+(setq battery-mode-line-format "%L: %t, %p%%%%")
#+END_SRC
Use an =:eval= form to align modeline contents.
@@ -757,7 +751,7 @@ RIGHT aligned respectively."
(cond ((string= (system-name) "Upsilon")
(format "%s | %s"
(mode-line-time)
- (mode-line-battery-status)))
+ battery-mode-line-string))
(t (mode-line-time)))))))
#+END_SRC

© 2015 - 2026 Jakob L. Kreuze