1 ;;; init-themes.el --- Defaults for themes -*- lexical-binding: t -*-
5 (require-package 'spacemacs-theme
)
8 ;; Auto load gui appearance color by time
9 (setq current-theme
(load-theme 'spacemacs-light t
))
10 (defun myinc/toggle-theme
()
11 "Toggle appearance color between light mode and dark mode."
12 (setq hour
(string-to-number (substring (current-time-string) 11 13)))
13 (if (member hour
(number-sequence 6 17)) ; 6:00 - 17:59
14 (setq now
'(load-theme 'spacemacs-light t
))
15 (setq now
'(load-theme 'spacemacs-dark t
)))
16 (if (equal now current-theme
) nil
(setq current-theme now
) (eval now
)))
17 (if (display-graphic-p)
18 (add-hook 'after-init-hook
19 (lambda () (run-with-timer 0 3600 'myinc
/toggle-theme
)))
20 (add-hook 'after-init-hook
21 (lambda () (load-theme 'spacemacs-dark t
))))
24 ;; switch appearance colors by F5
25 ;; (when (display-graphic-p)
26 ;; (defun myinc/toggle-theme ()
27 ;; "Toggle between light mode and dark mode."
28 ;; (if (eq (car custom-enabled-themes) 'spacemacs-dark)
29 ;; (disable-theme 'spacemacs-dark)
30 ;; (load-theme 'spacemacs-dark))))
31 ;; (global-set-key [f5] 'my/inc/toggle-theme)
34 ;; Unset background color in terminal
35 (defun on-after-init (&optional frame
)
36 "Unset Background colours in terminal FRAME."
37 (or frame
(setq frame
(selected-frame)))
38 (unless (display-graphic-p frame
)
39 (set-face-background 'default
"unspecified-bg" frame
)
40 (set-face-background 'mode-line
"unspecified-bg" frame
)
41 (set-face-background 'mode-line-inactive
"unspecified-bg" frame
)
42 (set-face-background 'linum
"unspecified-bg" frame
)))
43 (add-hook 'after-make-frame-functions
'on-after-init
)
44 (add-hook 'window-setup-hook
'on-after-init
)
47 ;; Don't prompt to confirm theme safety. This avoids problems with
48 ;; first-time startup on Emacs > 26.3.
49 (setq custom-safe-themes t
)
52 ;; Ensure that themes will be applied even if they have not been customized
53 (defun reapply-themes ()
54 "Forcibly load the themes listed in `custom-enabled-themes'."
55 (dolist (theme custom-enabled-themes
)
56 (unless (custom-theme-p theme
)
59 `(custom-enabled-themes (quote ,custom-enabled-themes
))))
60 (add-hook 'after-init-hook
'reapply-themes
)
62 (when (maybe-require-package 'dimmer
)
63 (setq-default dimmer-fraction
0.15)
64 (add-hook 'after-init-hook
'dimmer-mode
)
65 (with-eval-after-load 'dimmer
66 ;; TODO: file upstream as a PR
67 (advice-add 'frame-set-background-mode
:after
68 (lambda (&rest args
) (dimmer-process-all))))
69 (with-eval-after-load 'dimmer
70 ;; Don't dim in terminal windows. Even with 256 colours it can
71 ;; lead to poor contrast. Better would be to vary dimmer-fraction
72 ;; according to frame type.
73 (defun sanityinc/display-non-graphic-p
()
74 (not (display-graphic-p)))
75 (add-to-list 'dimmer-exclusion-predicates
76 'sanityinc
/display-non-graphic-p
)))
78 (provide 'init-themes
)
79 ;;; init-themes.el ends here