From 4aaeeb509ce215777834849ab4c50a5ae6d7b97a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 24 Feb 2019 13:57:01 -0500 Subject: [PATCH] Auto-determine ns-appearance parameter on MacOS This is experimental. It will adapt the frame titlebar's theme depending on the background of the loaded theme. --- core/core-os.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/core-os.el b/core/core-os.el index a7fd04298..945a57874 100644 --- a/core/core-os.el +++ b/core/core-os.el @@ -51,7 +51,21 @@ exec-path-from-shell-debug doom-debug-mode exec-path-from-shell-variables (nconc exec-path-from-shell-variables '("LC_CTYPE" "LC_ALL" "LANG"))) - (exec-path-from-shell-initialize)))) + (exec-path-from-shell-initialize))) + + (add-to-list 'default-frame-alist '(ns-transparent-titlebar . t)) + (defun +doom|determine-ns-appearance () + (let ((appearance (cl-destructuring-bind (r g b) (doom-name-to-rgb "#E5E9F0") + (if (> (+ (* r 0.2126) + (* g 0.7152) + (* b 0.0722)) + 0.45) + 'light + 'dark)))) + (setf (alist-get 'ns-appearance default-frame-alist) appearance) + (dolist (frame (frame-list)) + (set-frame-parameter frame 'ns-appearance appearance)))) + (add-hook 'doom-load-theme-hook #'+doom|determine-ns-appearance)) (IS-LINUX (setq x-gtk-use-system-tooltips nil ; native tooltips are ugly!