diff --git a/emacs/.emacs.d/config/init-mac.el b/emacs/.emacs.d/config/init-mac.el new file mode 100644 index 0000000..304fecb --- /dev/null +++ b/emacs/.emacs.d/config/init-mac.el @@ -0,0 +1,28 @@ +;; -*- lexical-binding: t; -*- + +(defvar my-light-theme 'jdormit-doom-solarized-light) +(defvar my-dark-theme 'doom-solarized-dark) + +(defun mac-appearance () (plist-get (mac-application-state) :appearance)) + +(defun dark-theme-enabled? () + (string-equal (mac-appearance) + "NSAppearanceNameDarkAqua")) + +(defun set-theme-from-system () + (if (dark-theme-enabled?) + (consult-theme my-dark-theme) + (consult-theme my-light-theme))) + +(defvar theme-timer-status-cache (mac-appearance)) +(defun theme-timer-fn () + (let ((appearance (mac-appearance))) + (when (not (string-equal appearance theme-timer-status-cache)) + (set-theme-from-system) + (setq theme-timer-status-cache appearance)))) +(defun theme-timer-hook () + (run-at-time "2 sec" 2 #'theme-timer-fn)) + +(add-hook 'after-init-hook #'theme-timer-hook) + +(provide 'init-mac) diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index 369beb9..f334078 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -94,6 +94,7 @@ (require 'init-js) (require 'init-rust) (require 'init-web) +(require 'init-swift) (require 'init-xml) (require 'init-yaml) (require 'init-groovy) @@ -113,6 +114,8 @@ (require 'init-wallabag) (require 'init-lola) (require 'handwriting) +(when (string-equal system-type "darwin") + (require 'init-mac)) (load (expand-file-name (concat user-emacs-directory "local.el")) 'noerror 'nomessage)