load theme earlier, update awesome-tray

This commit is contained in:
2025-06-16 22:40:01 +02:00
parent 5a1ee56a85
commit 56022f7f8b
11 changed files with 1988 additions and 941 deletions

View File

@@ -160,32 +160,139 @@ DISPLAY-START: `integer', e.g. 3820"
(my-view-gnuplot))))
(use-package awesome-tray
:defer 0.2
;;:after my-theme
:hook (after-init . awesome-tray-mode)
:config
(setq awesome-tray-info-padding-right 1)
(setq awesome-tray-buffer-name-buffer-changed t)
(setq awesome-tray-mode-line-active-color "#008b8b")
(setq awesome-tray-mode-line-inactive-color "#333333")
;; see available modules in `awesome-tray-module-alist'
(setq awesome-tray-file-path-show-filename nil)
(setq awesome-tray-file-path-truncated-name-length 2)
(setq awesome-tray-file-path-full-dirname-levels 2)
;; flycheck custom string
(defun my-awesome-tray-module-flycheck-info ()
(string-trim (flycheck-mode-line-status-text)))
(let ((flycheck-mode-line-prefix "fc"))
(string-trim (flycheck-mode-line-status-text))))
;; flycheck color string
(defface my-awesome-tray-module-flycheck-face
(list (list t (list :foreground (face-foreground 'font-lock-warning-face))))
"Flycheck module face."
:group 'awesome-tray)
;; flycheck add as module
(add-to-list 'awesome-tray-module-alist
'("flycheck" . (my-awesome-tray-module-flycheck-info my-awesome-tray-module-flycheck-face)))
(setq awesome-tray-active-modules ;; circe parent-dir battery
'("flycheck" . (my-awesome-tray-module-flycheck-info my-awesome-tray-module-flycheck-face)))
;; flymake custom string
(defun my-awesome-tray-module-flymake-info ()
"A module for showing Flymake state."
;; Parts of the code are from doom-modeline package
(with-demoted-errors
""
(if (and (featurep 'flymake) flymake--state)
(let* ((known (hash-table-keys flymake--state))
(running (flymake-running-backends))
(disabled (flymake-disabled-backends))
(reported (flymake-reporting-backends))
(disabledp (and disabled (null running)))
(waiting (cl-set-difference running reported)))
(when-let
((flymake-state
(cond
(waiting "*")
;;(waiting "⏳")
((null known) "")
(disabledp "")
(t (let ((.error 0)
(.warning 0)
(.note 0))
(cl-loop
with warning-level = (warning-numeric-level :warning)
with note-level = (warning-numeric-level :debug)
for state being the hash-values of flymake--state
do (cl-loop
with diags = (flymake--state-diags state)
for diag in diags do
(let ((severity (flymake--lookup-type-property (flymake--diag-type diag) 'severity
(warning-numeric-level :error))))
(cond ((> severity warning-level) (cl-incf .error))
((> severity note-level) (cl-incf .warning))
(t (cl-incf .note))))))
(let ((num (+ .error .warning .note)))
(if (> num 0)
(string-clean-whitespace
(string-join
(list
(when (>= .error 0)
;; "🔴:"
(concat "" (propertize (number-to-string .error) 'face 'awesome-tray-module-flymake-error)))
(when (>= .warning 0)
;; "🟠:"
(concat "" (propertize (number-to-string .warning) 'face 'awesome-tray-module-flymake-warning)))
(when (>= .note 0)
;; "🔵:"
(concat "" (propertize (number-to-string .note) 'face 'awesome-tray-module-flymake-note)))
)
":" ;; " " joining string
))
"" ;; "🟢" no error/warning/note
)))))))
flymake-state)))))
;; flycheck add as module
;; (add-to-list 'awesome-tray-module-alist
;; '("flymake" . (my-awesome-tray-module-flymake-info nil)))
(add-to-list 'awesome-tray-module-alist
'("flymake" . (my-awesome-tray-module-flymake-info my-awesome-tray-module-flycheck-face)))
;; doc-view custom string
(defun my-awesome-tray-module-doc-view-page-info ()
(with-demoted-errors
""
(cond
((and (derived-mode-p 'eaf-mode)
(string-equal eaf--buffer-app-name "pdf-viewer"))
(eaf-call-sync "execute_function" eaf--buffer-id "get_progress"))
((featurep 'pdf-view)
(let ((state
(cond ((derived-mode-p 'pdf-view-mode) (format "%d/%d" (eval '(pdf-view-current-page)) (pdf-cache-number-of-pages)))
(t ""))))
state))
((featurep 'doc-view)
(let ((state
(cond ((derived-mode-p 'doc-view-mode) (format "%d/%d" (eval '(doc-view-current-page)) (doc-view-last-page-number)))
(t ""))))
state))
(t ""))))
(defun my-awesome-tray-module-location-or-page-info ()
"Show Location or PDF page depends on current mode."
(let ((page-info (my-awesome-tray-module-doc-view-page-info)))
(if (string= page-info "")
(awesome-tray-module-location-info)
page-info)))
;; doc-view add as module
(add-to-list 'awesome-tray-module-alist
'("location-or-page" . (my-awesome-tray-module-location-or-page-info awesome-tray-module-location-face)))
;; see available modules in `awesome-tray-module-alist'
(setq awesome-tray-active-modules
'("file-path"
"buffer-name"
"buffer-read-only"
"location"
;; "location"
"location-or-page"
"mode-name"
"flycheck"
"flymake"
"git"))
(set-face-foreground 'awesome-tray-module-file-path-face (face-foreground 'font-lock-keyword-face))
(set-face-foreground 'awesome-tray-module-buffer-name-face (face-foreground 'font-lock-constant-face))
(set-face-foreground 'awesome-tray-module-location-face (face-foreground 'vertical-border))
(set-face-foreground 'awesome-tray-module-location-or-page-face (face-foreground 'vertical-border))
(set-face-foreground 'awesome-tray-module-mode-name-face (face-foreground 'font-lock-string-face))
(defun my-awesome-tray-module-file-path-info-advice (&rest args)
"If file path is same as buffer name omit output."
@@ -201,7 +308,7 @@ DISPLAY-START: `integer', e.g. 3820"
(concat (buffer-name) awesome-tray-buffer-name-buffer-changed-style)
(buffer-name))
(format "%s" (buffer-name))))
(awesome-tray-mode 1))
)
(use-package doc-view
:defer t
@@ -233,6 +340,7 @@ DISPLAY-START: `integer', e.g. 3820"
(use-package dashboard
:delight (dashboard-mode "Db") ;; "\u01F153
:hook (after-init . dashboard-setup-startup-hook) ;; activate `dashboard'
:config
;; see `dashboad-widget'
(setq dashboard-icon-type 'all-the-icons)
@@ -461,9 +569,7 @@ See also `dashboard-insert-section' for the sequence of elements."
`(lambda (&rest _) (switch-to-buffer ,el))
(abbreviate-file-name el)))
(add-to-list 'dashboard-item-generators '(custom . dashboard-insert-custom))
;; activate `dashboard'
(dashboard-setup-startup-hook))
)
;; too slow if all levels are displayed for a medium large file,
;; therefore not all levels and if toggled on and mode default off