mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 19:19:53 +00:00
[Feature] An indicator for battery status with fancy-battery.
This commit is contained in:
parent
2ae39ff5ca
commit
9f2a0183fc
3 changed files with 71 additions and 5 deletions
|
@ -35,10 +35,11 @@ The `doom-modeline` was designed for minimalism, and offers:
|
||||||
- An indicator for current input method
|
- An indicator for current input method
|
||||||
- An indicator for `LSP` state
|
- An indicator for `LSP` state
|
||||||
- An indicator for github notifications
|
- An indicator for github notifications
|
||||||
- An indicator for unread emails with `mu4e-alert`.
|
- An indicator for unread emails with `mu4e-alert`
|
||||||
- An indicator for buffer position which is compatible with `nyan-mode`
|
- An indicator for buffer position which is compatible with `nyan-mode`
|
||||||
- An indicator for party parrot
|
- An indicator for party parrot
|
||||||
- An indicator for PDF page number
|
- An indicator for PDF page number
|
||||||
|
- An indicator for battery status with `fancy-battery`
|
||||||
- Truncated file name, file icon, buffer state and project name in buffer
|
- Truncated file name, file icon, buffer state and project name in buffer
|
||||||
information segment, which is compatible with `projectile` and `project`
|
information segment, which is compatible with `projectile` and `project`
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
(defvar anzu--total-matched)
|
(defvar anzu--total-matched)
|
||||||
(defvar anzu-cons-mode-line-p)
|
(defvar anzu-cons-mode-line-p)
|
||||||
(defvar aw-keys)
|
(defvar aw-keys)
|
||||||
|
(defvar battery-echo-area-format)
|
||||||
(defvar evil-ex-active-highlights-alist)
|
(defvar evil-ex-active-highlights-alist)
|
||||||
(defvar evil-ex-argument)
|
(defvar evil-ex-argument)
|
||||||
(defvar evil-ex-range)
|
(defvar evil-ex-range)
|
||||||
|
@ -53,6 +54,8 @@
|
||||||
(defvar evil-visual-beginning)
|
(defvar evil-visual-beginning)
|
||||||
(defvar evil-visual-end)
|
(defvar evil-visual-end)
|
||||||
(defvar evil-visual-selection)
|
(defvar evil-visual-selection)
|
||||||
|
(defvar fancy-battery-last-status)
|
||||||
|
(defvar fancy-battery-show-percentage)
|
||||||
(defvar flycheck-current-errors)
|
(defvar flycheck-current-errors)
|
||||||
(defvar flycheck-mode-menu-map)
|
(defvar flycheck-mode-menu-map)
|
||||||
(defvar flymake--backend-state)
|
(defvar flymake--backend-state)
|
||||||
|
@ -80,6 +83,7 @@
|
||||||
(declare-function avy-tree 'avy)
|
(declare-function avy-tree 'avy)
|
||||||
(declare-function aw-update 'ace-window)
|
(declare-function aw-update 'ace-window)
|
||||||
(declare-function aw-window-list 'ace-window)
|
(declare-function aw-window-list 'ace-window)
|
||||||
|
(declare-function battery-format 'battery)
|
||||||
(declare-function evil-delimited-arguments 'evil-common)
|
(declare-function evil-delimited-arguments 'evil-common)
|
||||||
(declare-function evil-emacs-state-p 'evil-states)
|
(declare-function evil-emacs-state-p 'evil-states)
|
||||||
(declare-function evil-force-normal-state 'evil-commands)
|
(declare-function evil-force-normal-state 'evil-commands)
|
||||||
|
@ -1660,6 +1664,66 @@ we don't want to remove that so we just return the original."
|
||||||
tracking-buffers)))
|
tracking-buffers)))
|
||||||
" ")))
|
" ")))
|
||||||
|
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; fancy battery
|
||||||
|
;;
|
||||||
|
|
||||||
|
(doom-modeline-def-segment fancy-battery
|
||||||
|
(when (and (doom-modeline--active)
|
||||||
|
(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)))
|
||||||
|
(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))
|
||||||
|
(help-echo (if battery-echo-area-format
|
||||||
|
(battery-format battery-echo-area-format
|
||||||
|
fancy-battery-last-status)
|
||||||
|
"Battery status not available")))
|
||||||
|
(concat
|
||||||
|
" "
|
||||||
|
(if status
|
||||||
|
(concat
|
||||||
|
(propertize icon
|
||||||
|
'face (if doom-modeline-icon
|
||||||
|
`(
|
||||||
|
:height ,(doom-modeline-icon-height 1.3)
|
||||||
|
:family ,(all-the-icons-icon-family icon)
|
||||||
|
:inherit ,face
|
||||||
|
)
|
||||||
|
face)
|
||||||
|
'help-echo help-echo)
|
||||||
|
(propertize doom-modeline-vspc 'help-echo help-echo)
|
||||||
|
(propertize status
|
||||||
|
'face face
|
||||||
|
'help-echo help-echo))
|
||||||
|
;; Battery status is not available
|
||||||
|
(if doom-modeline-icon
|
||||||
|
(doom-modeline-icon-material "battery_unknown" :height 1.1 :v-adjust -0.225 :face 'error)
|
||||||
|
(propertize "N/A" 'face 'error)))
|
||||||
|
" "))))
|
||||||
|
|
||||||
(provide 'doom-modeline-segments)
|
(provide 'doom-modeline-segments)
|
||||||
|
|
||||||
;;; doom-modeline-segments.el ends here
|
;;; doom-modeline-segments.el ends here
|
||||||
|
|
|
@ -54,10 +54,11 @@
|
||||||
;; - An indicator for debug state
|
;; - An indicator for debug state
|
||||||
;; - An indicator for LSP state
|
;; - An indicator for LSP state
|
||||||
;; - An indicator for github notifications
|
;; - An indicator for github notifications
|
||||||
;; - An indicator for unread emails with mu4e-alert.
|
;; - An indicator for unread emails with mu4e-alert
|
||||||
;; - An indicator for buffer position which is compatible with nyan-mode
|
;; - An indicator for buffer position which is compatible with nyan-mode
|
||||||
;; - An indicator for party parrot
|
;; - An indicator for party parrot
|
||||||
;; - An indicator for PDF page number
|
;; - An indicator for PDF page number
|
||||||
|
;; - An indicator for battery status with fancy-battery
|
||||||
;; - Truncated file name, file icon, buffer state and project name in buffer
|
;; - Truncated file name, file icon, buffer state and project name in buffer
|
||||||
;; information segment, which is compatible with projectile and project
|
;; information segment, which is compatible with projectile and project
|
||||||
;;
|
;;
|
||||||
|
@ -84,7 +85,7 @@
|
||||||
|
|
||||||
(doom-modeline-def-modeline 'main
|
(doom-modeline-def-modeline 'main
|
||||||
'(bar workspace-number window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info remote-host buffer-position parrot selection-info)
|
'(bar workspace-number window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info remote-host buffer-position parrot selection-info)
|
||||||
'(misc-info persp-name lsp irc mu4e github debug minor-modes input-method buffer-encoding major-mode process vcs checker))
|
'(misc-info persp-name lsp irc mu4e github debug fancy-battery minor-modes input-method buffer-encoding major-mode process vcs checker))
|
||||||
|
|
||||||
(doom-modeline-def-modeline 'minimal
|
(doom-modeline-def-modeline 'minimal
|
||||||
'(bar matches " " buffer-info)
|
'(bar matches " " buffer-info)
|
||||||
|
@ -92,11 +93,11 @@
|
||||||
|
|
||||||
(doom-modeline-def-modeline 'special
|
(doom-modeline-def-modeline 'special
|
||||||
'(bar window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info-simple buffer-position parrot selection-info)
|
'(bar window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info-simple buffer-position parrot selection-info)
|
||||||
'(misc-info lsp debug minor-modes input-method irc-buffers buffer-encoding major-mode process checker))
|
'(misc-info lsp irc-buffers debug fancy-battery minor-modes input-method buffer-encoding major-mode process checker))
|
||||||
|
|
||||||
(doom-modeline-def-modeline 'project
|
(doom-modeline-def-modeline 'project
|
||||||
'(bar " " buffer-default-directory)
|
'(bar " " buffer-default-directory)
|
||||||
'(misc-info mu4e github debug " " major-mode " "))
|
'(misc-info mu4e github debug fancy-battery " " major-mode " "))
|
||||||
|
|
||||||
(doom-modeline-def-modeline 'media
|
(doom-modeline-def-modeline 'media
|
||||||
'(bar window-number buffer-size buffer-info)
|
'(bar window-number buffer-size buffer-info)
|
||||||
|
|
Loading…
Reference in a new issue