mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
[Enhancement] More meaningful icons for battery status.
This commit is contained in:
parent
ef2ab6015f
commit
5f9d9a2e48
3 changed files with 46 additions and 29 deletions
|
@ -72,13 +72,13 @@ The `doom-modeline` was designed for minimalism, and offers:
|
|||
![evil_insert_state](https://user-images.githubusercontent.com/140797/49694461-8b5c2100-fbc5-11e8-993e-d97baa9f01af.png
|
||||
"Evil Insert State")
|
||||
|
||||
![lsp_version](https://user-images.githubusercontent.com/140797/53586076-f95b2780-3bb9-11e9-83bf-ec6c60d1ff1a.png
|
||||
![lsp_version](https://user-images.githubusercontent.com/140797/53592864-c751c180-3bc9-11e9-9914-493007c013d5.png
|
||||
"Perspective, LSP, Version, VCS and Flycheck")
|
||||
|
||||
![perspective](https://user-images.githubusercontent.com/140797/49694481-e0983280-fbc5-11e8-8cb2-c8d2e782bcdb.png
|
||||
"Perspective, LSP, Version and VCS")
|
||||
|
||||
![notifications](https://user-images.githubusercontent.com/140797/53586463-cfeecb80-3bba-11e9-8ae7-450509fa5494.png
|
||||
![notifications](https://user-images.githubusercontent.com/140797/53592683-64602a80-3bc9-11e9-8054-91f79aa930b9.png
|
||||
"Notifications")
|
||||
|
||||
![minions](https://user-images.githubusercontent.com/140797/50301291-de857c00-04c1-11e9-84c5-bfbc8de8295f.png
|
||||
|
@ -90,7 +90,7 @@ The `doom-modeline` was designed for minimalism, and offers:
|
|||
![nyan_parrot](https://user-images.githubusercontent.com/140797/51301061-da209480-1a68-11e9-9f64-905d889df9d6.png
|
||||
"Nyan and Parrot")
|
||||
|
||||
![battery](https://user-images.githubusercontent.com/140797/53586243-53f48380-3bba-11e9-9509-e936f466c8aa.png
|
||||
![battery](https://user-images.githubusercontent.com/140797/53593622-ba35d200-3bcb-11e9-85b3-38d64d05c127.png
|
||||
"Fancy Battery")
|
||||
|
||||
## Install
|
||||
|
|
|
@ -450,6 +450,11 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|||
(when doom-modeline-icon
|
||||
(apply #'all-the-icons-material args)))
|
||||
|
||||
(defun doom-modeline-icon-alltheicon (&rest args)
|
||||
"Display alltheicon via ARGS."
|
||||
(when doom-modeline-icon
|
||||
(apply #'all-the-icons-alltheicon args)))
|
||||
|
||||
(defun doom-modeline-icon-for-mode (&rest args)
|
||||
"Display icon for major mode via ARGS."
|
||||
(when doom-modeline-icon
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
(defvar evil-visual-end)
|
||||
(defvar evil-visual-selection)
|
||||
(defvar fancy-battery-last-status)
|
||||
(defvar fancy-battery-show-percentage)
|
||||
(defvar flycheck-current-errors)
|
||||
(defvar flycheck-mode-menu-map)
|
||||
(defvar flymake--backend-state)
|
||||
|
@ -1675,32 +1674,45 @@ we don't want to remove that so we just return the original."
|
|||
(bound-and-true-p fancy-battery-mode))
|
||||
;; Remove the default mode-line
|
||||
(setq global-mode-string (delq 'fancy-battery-mode-line global-mode-string))
|
||||
(let* ((time (cdr (assq ?t fancy-battery-last-status)))
|
||||
(let* ((charging? (string-equal "AC" (cdr (assoc ?L fancy-battery-last-status))))
|
||||
(percentage (cdr (assq ?p fancy-battery-last-status)))
|
||||
(face (pcase (cdr (assq ?b fancy-battery-last-status))
|
||||
("!" 'fancy-battery-critical)
|
||||
("+" 'fancy-battery-charging)
|
||||
("-" 'fancy-battery-discharging)
|
||||
(_ 'success)))
|
||||
(icon (pcase (cdr (assq ?b fancy-battery-last-status))
|
||||
("!"
|
||||
(if doom-modeline-icon
|
||||
(doom-modeline-icon-material "battery_alert" :height 1.1 :v-adjust -0.225 :face face)
|
||||
(propertize "!" 'face face)))
|
||||
("+"
|
||||
(if doom-modeline-icon
|
||||
(doom-modeline-icon-material "battery_charging_full" :height 1.1 :v-adjust -0.225 :face face)
|
||||
(propertize "+" 'face face)))
|
||||
(_
|
||||
(if doom-modeline-icon
|
||||
(doom-modeline-icon-material "battery_std" :height 1.1 :v-adjust -0.225 :face face)
|
||||
(propertize "-" 'face face)))))
|
||||
(status (if (or fancy-battery-show-percentage (string-equal time "N/A"))
|
||||
(and percentage (concat percentage "%%%%"))
|
||||
time))
|
||||
(percentage-number (string-to-number percentage))
|
||||
(face (cond
|
||||
(charging? 'fancy-battery-charging)
|
||||
((< percentage-number 10) 'fancy-battery-critical)
|
||||
((< percentage-number 25) 'fancy-battery-discharging)
|
||||
((< percentage-number 50) 'mode-line)
|
||||
((< percentage-number 75) 'mode-line)
|
||||
((< percentage-number 95) 'mode-line)
|
||||
(t 'fancy-battery-charging)))
|
||||
(icon (cond
|
||||
(charging?
|
||||
(if doom-modeline-icon
|
||||
(doom-modeline-icon-alltheicon "battery-charging" :height 1.3 :v-adjust -0.1 :face face)
|
||||
(propertize "+" 'face face)))
|
||||
((> percentage-number 95)
|
||||
(if doom-modeline-icon
|
||||
(doom-modeline-icon-faicon "battery-full" :height 1.1 :v-adjust -0.0575 :face face)
|
||||
(propertize "-" 'face face)))
|
||||
((> percentage-number 75)
|
||||
(if doom-modeline-icon
|
||||
(doom-modeline-icon-faicon "battery-three-quarters" :height 1.1 :v-adjust -0.0575 :face face)
|
||||
(propertize "-" 'face face)))
|
||||
((> percentage-number 50)
|
||||
(if doom-modeline-icon
|
||||
(doom-modeline-icon-faicon "battery-half" :height 1.1 :v-adjust -0.0575 :face face)
|
||||
(propertize "-" 'face face)))
|
||||
((> percentage-number 25)
|
||||
(if doom-modeline-icon
|
||||
(doom-modeline-icon-faicon "battery-quarter" :height 1.1 :v-adjust -0.0575 :face face)
|
||||
(propertize "!" 'face face)))
|
||||
(t
|
||||
(if doom-modeline-icon
|
||||
(doom-modeline-icon-faicon "battery-empty" :height 1.1 :v-adjust -0.0575 :face face)
|
||||
(propertize "!" 'face face)))))
|
||||
(status (and percentage (concat percentage "%%%%")))
|
||||
(help-echo (if battery-echo-area-format
|
||||
(battery-format battery-echo-area-format
|
||||
fancy-battery-last-status)
|
||||
(battery-format battery-echo-area-format fancy-battery-last-status)
|
||||
"Battery status not available")))
|
||||
(concat
|
||||
" "
|
||||
|
@ -1709,7 +1721,7 @@ we don't want to remove that so we just return the original."
|
|||
(propertize icon
|
||||
'face (if doom-modeline-icon
|
||||
`(
|
||||
:height ,(doom-modeline-icon-height 1.3)
|
||||
:height ,(doom-modeline-icon-height (if charging? 1.69 1.2))
|
||||
:family ,(all-the-icons-icon-family icon)
|
||||
:inherit ,face
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue