forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-themes.el
58 lines (44 loc) · 1.83 KB
/
init-themes.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
;;; init-themes.el --- Defaults for themes -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(require-package 'color-theme-sanityinc-solarized)
(require-package 'color-theme-sanityinc-tomorrow)
;; Don't prompt to confirm theme safety. This avoids problems with
;; first-time startup on Emacs > 26.3.
(setq custom-safe-themes t)
;; If you don't customize it, this is the theme you get.
(setq-default custom-enabled-themes '(sanityinc-tomorrow-bright))
;; Ensure that themes will be applied even if they have not been customized
(defun reapply-themes ()
"Forcibly load the themes listed in `custom-enabled-themes'."
(dolist (theme custom-enabled-themes)
(unless (custom-theme-p theme)
(load-theme theme)))
(custom-set-variables `(custom-enabled-themes (quote ,custom-enabled-themes))))
(add-hook 'after-init-hook 'reapply-themes)
;; Toggle between light and dark
(defun light ()
"Activate a light color theme."
(interactive)
(setq custom-enabled-themes '(sanityinc-tomorrow-day))
(reapply-themes))
(defun dark ()
"Activate a dark color theme."
(interactive)
(setq custom-enabled-themes '(sanityinc-tomorrow-bright))
(reapply-themes))
(when (maybe-require-package 'dimmer)
(setq-default dimmer-fraction 0.15)
(add-hook 'after-init-hook 'dimmer-mode)
(with-eval-after-load 'dimmer
;; TODO: file upstream as a PR
(advice-add 'frame-set-background-mode :after (lambda (&rest args) (dimmer-process-all))))
(with-eval-after-load 'dimmer
;; Don't dim in terminal windows. Even with 256 colours it can
;; lead to poor contrast. Better would be to vary dimmer-fraction
;; according to frame type.
(defun sanityinc/display-non-graphic-p ()
(not (display-graphic-p)))
(add-to-list 'dimmer-exclusion-predicates 'sanityinc/display-non-graphic-p)))
(provide 'init-themes)
;;; init-themes.el ends here