summaryrefslogtreecommitdiff
path: root/bin/modus2css.el
blob: d6a57c876e7c2a3c5a10f7fe9ad42b324ee86b85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(defun mapping2css (mapping)
  (let* ((key (symbol-name (car mapping)))
	 (value (cadr mapping))
	 (color (pcase value
		  ((pred stringp) value)
		  ('unspecified "none")
		  ((pred symbolp) (concat "var(--" (symbol-name value) ")")))))
    (concat "--" key ": " color ";")))

(with-current-buffer (get-buffer-create "*modus2css*")
  (insert
   (string-join
    `(":root {"
      ,@(mapcar (lambda (line) (concat "    " line))
		(mapcar 'mapping2css (modus-themes-get-theme-palette 'modus-operandi t t)))
      "}"
      ""
      "@media (prefers-color-scheme: dark) {"
      "    :root {"
      ,@(mapcar (lambda (line) (concat "        " line))
		(mapcar 'mapping2css (modus-themes-get-theme-palette 'modus-vivendi t t)))
      "    }"
      "}")
    "\n")))