summaryrefslogtreecommitdiff
path: root/bin/modus2css.el
diff options
context:
space:
mode:
Diffstat (limited to 'bin/modus2css.el')
-rw-r--r--bin/modus2css.el24
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/modus2css.el b/bin/modus2css.el
new file mode 100644
index 0000000..d6a57c8
--- /dev/null
+++ b/bin/modus2css.el
@@ -0,0 +1,24 @@
1(defun mapping2css (mapping)
2 (let* ((key (symbol-name (car mapping)))
3 (value (cadr mapping))
4 (color (pcase value
5 ((pred stringp) value)
6 ('unspecified "none")
7 ((pred symbolp) (concat "var(--" (symbol-name value) ")")))))
8 (concat "--" key ": " color ";")))
9
10(with-current-buffer (get-buffer-create "*modus2css*")
11 (insert
12 (string-join
13 `(":root {"
14 ,@(mapcar (lambda (line) (concat " " line))
15 (mapcar 'mapping2css (modus-themes-get-theme-palette 'modus-operandi t t)))
16 "}"
17 ""
18 "@media (prefers-color-scheme: dark) {"
19 " :root {"
20 ,@(mapcar (lambda (line) (concat " " line))
21 (mapcar 'mapping2css (modus-themes-get-theme-palette 'modus-vivendi t t)))
22 " }"
23 "}")
24 "\n")))