Repository navigation
Expand file tree
/
Copy pathmodus-ewal-theme.el
More file actions
139 lines (119 loc) · 4.85 KB
/
Copy pathmodus-ewal-theme.el
File metadata and controls
139 lines (119 loc) · 4.85 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
;;; modus-ewal-theme.el --- Modus theme that uses pywal colors powered by ewal -*- lexical-binding: t; -*-
;; Copyright (C) 2026
;; Author: Oliwier Czerwiński <oliwier.czerwi@proton.me>
;; Keywords: faces theme
;; Version: 20260715
;; URL: https://github.com/deadendpl/modus-ewal-theme
;; Package-Requires: ((emacs "25.1") (modus-themes "5.2.0") (ewal "0.2.1"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; A theme built with modus that uses pywal colors and tries to look
;; good out of the box.
;; It should look fine with both dark and light color schemes.
;;; Code:
(require 'ewal)
(require 'modus-themes)
(defgroup modus-ewal-theme nil
"User options for modus-ewal-theme."
:group 'faces)
(defvar modus-ewal-theme-base-palette nil
"The base pywal palette edited to work with modus.")
(defvar modus-ewal-theme-modus-palette nil
"Palette generated based on `modus-ewal-theme-base-palette'.")
(defvar modus-ewal-theme-custom-faces
'(
;; region by default is wonky
`(region ((,c :background
,(modus-themes-generate-color-blend
bg-main
(if (modus-themes-color-dark-p bg-main)
"#ffffff"
"#000000")
0.9))))
;; in meow, it looked off
`(secondary-selection
((,c :background
,(modus-themes-generate-color-blend
bg-main
(if (modus-themes-color-dark-p bg-main)
"#ffffff"
"#000000")
(if (modus-themes-color-dark-p bg-main)
0.85
0.7)))))
`(fill-column-indicator
((,c :background unspecified
:foreground ,(modus-themes-generate-color-blend
fg-main
(if (modus-themes-color-dark-p bg-main)
"#000000"
"#ffffff")
0.5))))
`(hl-line ((,c :background ,(modus-themes-generate-color-blend
bg-search-lazy
(if (modus-themes-color-dark-p bg-main)
"#000000"
"#ffffff")
0.8)))))
"Custom faces configuration.
Look at `modus-themes-faces' for an example.")
(defun modus-ewal-theme-reload-base-palette ()
"Regenerate the base palette."
(setq modus-ewal-theme-base-palette
(mapcar (lambda (element)
(list (car element) (cdr element)))
(let* ((colors (ewal-load-colors))
(colors (assq-delete-all 'comment colors))
(colors (assq-delete-all 'cursor colors))
(colors (assq-delete-all 'white colors))
(colors (assq-delete-all 'black colors)))
(setcar (assoc 'background colors) 'bg-main)
(setcar (assoc 'foreground colors) 'fg-main)
colors))))
(defun modus-ewal-theme-reload-modus-palette ()
"Regenerate the base palette."
(setq modus-ewal-theme-modus-palette
(modus-themes-generate-palette modus-ewal-theme-base-palette)))
(defun modus-ewal-theme-define-theme ()
"Define the theme."
(modus-themes-theme
'modus-ewal
'modus-themes
"A pywal theme."
(if (modus-themes-color-dark-p
(car (alist-get 'bg-main modus-ewal-theme-base-palette)))
'dark
'light)
'modus-ewal-theme-modus-palette
nil
nil
'modus-ewal-theme-custom-faces))
(defun modus-ewal-theme-generate-theme ()
"Generate the theme."
(if (not (ewal-load-colors))
(display-warning
'modus-ewal-theme
(format-message
"%s\n%s"
"`ewal-load-colors' returned nil - you need to have the json file specified in `ewal-json-file'."
"You may need to load the `modus-ewal-theme' package again."))
(modus-ewal-theme-reload-base-palette)
(modus-ewal-theme-reload-modus-palette)
(modus-ewal-theme-define-theme)))
(modus-ewal-theme-generate-theme)
;;;###autoload
(when load-file-name
(let ((dir (file-name-directory load-file-name)))
(unless (equal dir (expand-file-name "themes/" data-directory))
(add-to-list 'custom-theme-load-path dir))))
(provide-theme 'modus-ewal)
;;; modus-ewal-theme.el ends here