From cde763e436a6c7af1dda3484daa73f4b27126abe Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Sat, 14 Sep 2019 17:41:08 -0400 Subject: Update implementation of the modeline battery indicator. --- jakob.org | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'jakob.org') 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 -- cgit v1.3