Automatically toggle light and dark theme with macOS system appearance

This commit is contained in:
Dimitri Lozeve 2024-03-09 19:12:32 +01:00
parent ef038da6ac
commit efbc61c3d8

View file

@ -131,6 +131,14 @@
(setq ef-themes-to-toggle '(ef-day ef-night)) (setq ef-themes-to-toggle '(ef-day ef-night))
(mapc #'disable-theme custom-enabled-themes) (mapc #'disable-theme custom-enabled-themes)
(load-theme 'ef-night :no-confirm) (load-theme 'ef-night :no-confirm)
(when (eq window-system 'ns)
(defun dl/themes-toggle-with-system (appearance)
"Load dark or light theme depending on system appearance on macOS."
(mapc #'disable-theme custom-enabled-themes)
(pcase appearance
('light (load-theme 'ef-day :no-confirm))
('dark (load-theme 'ef-night :no-confirm))))
(add-hook 'ns-system-appearance-change-functions #'dl/themes-toggle-with-system))
:bind ("<f12>" . ef-themes-toggle)) :bind ("<f12>" . ef-themes-toggle))
(use-package diminish (use-package diminish