Change theme when system appearance changes

This commit is contained in:
larstvei 2023-06-11 00:26:07 +02:00
parent 4f5e1d9420
commit 684da8a8fd

View File

@ -409,9 +409,18 @@
available, defaulting to a light theme. available, defaulting to a light theme.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(let* ((variant (if (boundp 'ns-system-appearance) ns-system-appearance 'light)) (defun load-nano-theme (variant)
(theme (intern (concat "nano-" (symbol-name variant))))) (let ((theme (intern (concat "nano-" (symbol-name variant)))))
(load-theme theme t)) (load-theme theme t)))
(load-nano-theme (if (boundp 'ns-system-appearance) ns-system-appearance 'light))
#+END_SRC
Let's have Emacs change theme when the system appearance changes as well.
#+BEGIN_SRC emacs-lisp
(when (boundp 'ns-system-appearance-change-functions)
(add-hook 'ns-system-appearance-change-functions 'load-nano-theme))
#+END_SRC #+END_SRC
I want to be able to quickly switch between a light and a dark theme. I want to be able to quickly switch between a light and a dark theme.