From 520477884b27298887ebcea1d4e279934840150c Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Mon, 4 Mar 2024 15:31:55 -0500 Subject: [PATCH] ADD toggle for light and dark mode --- etc/conf.org | 82 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/etc/conf.org b/etc/conf.org index 718061b..f00d23c 100644 --- a/etc/conf.org +++ b/etc/conf.org @@ -455,10 +455,25 @@ This theme has good functionality for many different modes without being over-th Since I run emacs in [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html][client/server]] mode, the loaded theme can change depending on if the client is a terminal or server (terminals have far fewer colors). This makes the theme reset when terminal is loaded before gui or vice versa. #+BEGIN_SRC emacs-lisp -(defvar nd/theme 'spacemacs-dark) +(defvar nd/theme nil) +(defvar nd/theme-dark nil) (defvar nd/theme-window-loaded nil) (defvar nd/theme-terminal-loaded nil) +(defun nd/read-use-dark-mode-p () + "Return t if flag file permits us to use dark mode." + (let ((path "/tmp/emacs-use-dark-mode")) + (when (f-exists-p path) + (equal (s-trim (f-read-text path)) "1")))) + +(setq nd/theme-dark (nd/read-use-dark-mode-p)) + +(defmacro nd/choose-theme (light-stuff dark-stuff) + "Do LIGHT-STUFF or DARK-STUFF depending on the selected theme." + `(if nd/theme-dark ,dark-stuff ,light-stuff)) + +(setq nd/theme (nd/choose-theme 'spacemacs-light 'spacemacs-dark)) + (setq default-frame-alist '((font . "Dejavu Sans Mono-11"))) ;; required for emacsclient/daemon setup @@ -565,13 +580,19 @@ Some modes like to make popup windows (eg ediff). This prevents that. *** ace-window This is an elegant window selector. It displays a number in the corner when activated, and windows may be chosen by pressing the corresponding number. Note that spacemacs fails to make the numbers look nice so the theme code is a workaround to make them smaller and prettier. #+BEGIN_SRC emacs-lisp +(defvar nd/ace-window-fg nil) +(defvar nd/ace-window-bg nil) + +(setq nd/ace-window-fg (nd/choose-theme "#F6E0F9" "#292b2e")) +(setq nd/ace-window-bg (nd/choose-theme "#7A1686" "#292b2e")) + (use-package ace-window :straight t :config (setq aw-background t) - (custom-set-faces '(aw-leading-char-face - ((t (:foreground "#292b2e" - :background "#bc6ec5" + (custom-set-faces `(aw-leading-char-face + ((t (:foreground ,nd/ace-window-fg + :background ,nd/ace-window-bg :height 1.0 :box nil)))))) #+END_SRC @@ -584,10 +605,13 @@ This is an elegant window selector. It displays a number in the corner when acti (format "%-50s %s" b f) b))) +(defvar nd/ivy-match-bg nil) + +(setq nd/ivy-match-bg (nd/choose-theme "#D4C7F3" "#534573")) + (use-package ivy :straight t :delight - :custom-face (ivy-current-match ((t (:inherit bold :extend t :background "#534573")))) :config (setq ivy-use-virtual-buffers nil ivy-sort-max-size 30000 @@ -609,7 +633,10 @@ This is an elegant window selector. It displays a number in the corner when acti (ivy--alist-set 'ivy-format-functions-alist t #'ivy-format-function-line) (ivy-configure 'ivy-switch-buffer :display-transformer-fn #'nd/ivy-swith-buffer-transformer-fn) - (ivy-mode)) + (ivy-mode) + (set-face-attribute 'ivy-current-match nil :inherit 'bold :extend t :background nd/ivy-match-bg) + ;;(ivy-current-match ((t (:inherit bold :extend t :background 'nd/ivy-match-bg)))) + ) ;; ensure counsel and swiper are loaded (use-package counsel @@ -2187,13 +2214,18 @@ In terms of logging, I like to record the time of each change upon leaving any s **** colors Aesthetically, I like all my keywords to have bold colors. #+BEGIN_SRC emacs-lisp -(setq org-todo-keyword-faces - `((,org-x-kw-todo :foreground "light coral" :weight bold) - (,org-x-kw-next :foreground "khaki" :weight bold) - (,org-x-kw-done :foreground "light green" :weight bold) - (,org-x-kw-wait :foreground "orange" :weight bold) - (,org-x-kw-hold :foreground "violet" :weight bold) - (,org-x-kw-canc :foreground "deep sky blue" :weight bold))) +(setq + org-todo-keyword-faces + (-let (((todo next done wait hold canc) + (nd/choose-theme + '("indian red" "dark goldenrod" "forest green" "dark orange" "dark violet" "DodgerBlue1") + '("light coral" "khaki" "light green" "orange" "violet" "deep sky blue")))) + `((,org-x-kw-todo :foreground ,todo :weight bold) + (,org-x-kw-next :foreground ,next :weight bold) + (,org-x-kw-done :foreground ,done :weight bold) + (,org-x-kw-wait :foreground ,wait :weight bold) + (,org-x-kw-hold :foreground ,hold :weight bold) + (,org-x-kw-canc :foreground ,canc :weight bold)))) #+END_SRC *** links and IDs IDs and links are useful for meetings where I either reference tasks to discuss or reference action items to do in the future. @@ -2264,11 +2296,15 @@ Each group also has its own color, defined by its prefix symbol. (->> (alist-get prefix grouped-tags) (--map (list it :foreground color))))) (setq org-tag-faces - (append - (add-foreground org-x-tag-location-prefix "PaleGreen") - (add-foreground org-x-tag-resource-prefix "SkyBlue") - (add-foreground org-x-tag-misc-prefix "PaleGoldenrod") - (add-foreground org-x-tag-category-prefix "violet"))))) + (-let (((loc res misc cat) + (nd/choose-theme + '("medium sea green" "steel blue" "dark goldenrod" "dark violet") + '("PaleGreen" "SkyBlue" "PaleGoldenrod" "violet")))) + (append + (add-foreground org-x-tag-location-prefix loc) + (add-foreground org-x-tag-resource-prefix res) + (add-foreground org-x-tag-misc-prefix misc) + (add-foreground org-x-tag-category-prefix cat)))))) #+END_SRC *** properties The built-in =effort= is used as the fourth and final homonymous GTD context (the other three being covered above using tags). It is further restricted with =Effort_All= to allow easier filtering in the agenda. @@ -2443,9 +2479,15 @@ The modeline is a nice place to indicate if something is clocked in or out. Unfo Solution: flashy colors. #+BEGIN_SRC emacs-lisp +(defvar nd/spaceline-clock-fg nil) +(defvar nd/spaceline-clock-bg nil) + +(setq nd/spaceline-clock-fg (nd/choose-theme "#3E3D31" "#3E3D31")) +(setq nd/spaceline-clock-bg (nd/choose-theme "#88F918" "#66cd00")) + (defface nd/spaceline-highlight-clocked-face - `((t (:background "chartreuse3" - :foreground "#3E3D31" + `((t (:background ,nd/spaceline-clock-bg + :foreground ,nd/spaceline-clock-fg :inherit 'mode-line))) "Default highlight face for spaceline.")