;; -*- lexical-binding: t; -*- (use-package @package@ :if (or (daemonp) window-system)) (let ((light-mode-theme '@light-mode-theme@) (dark-mode-theme '@dark-mode-theme@)) (mapc #'disable-theme custom-enabled-themes) (load-theme light-mode-theme :noconfirm :noenable) (load-theme dark-mode-theme :noconfirm :noenable) (defun my/switch-theme-variant (mode) (interactive (list (intern (completing-read "Make it: " '("light" "dark") nil t)))) (cond ((eq mode 'dark) (disable-theme light-mode-theme) (enable-theme dark-mode-theme)) ((eq mode 'light) (disable-theme dark-mode-theme) (enable-theme light-mode-theme))) (modify-all-frames-parameters `((ns-appearance ,mode)))) (defun my/system-appearance () (if (and (eq system-type 'darwin) (string-equal "Dark" (string-trim-right (shell-command-to-string "defaults read -g AppleInterfaceStyle")))) 'dark 'light)) (defun my/match-theme-system-appearance () (interactive) (my/switch-theme-variant (my/system-appearance))) (my/switch-theme-variant (my/system-appearance)) (use-package kqueue :if (and (eq system-type 'darwin) window-system ) :config (progn (defun my/gp-notify-callback (event) (let* ((filename (elt event 2)) (basename (file-name-nondirectory filename))) (when (string-equal basename ".GlobalPreferences.plist") (my/match-theme-system-appearance)))) (setq my/kq-watcher-global-preferences (kqueue-add-watch (expand-file-name "~/Library/Preferences/") '(write) #'my/gp-notify-callback)))))