blob: 2d74e3b363851b35fffb716e6de70acf465c703c (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
(defvar wmii-unspecified-fg "black")
(defvar wmii-unspecified-bg "white")
(defvar wmii-unspecified-box "black")
(defun wmii-normalize-color (frame colorname &optional default)
"Given an Emacs colorname, normalize it to an \"#rrggbb\" string."
(let ((rgb (color-name-to-rgb (or colorname default) frame)))
(if rgb
(apply 'color-rgb-to-hex (append rgb '(2)))
(when default
(wmii-normalize-color frame default)))))
(defun wmii-face2triplet (face &optional frame)
"Dump an Emacs face as a WMII color triplet."
(let ((fg (face-foreground face frame 'default))
(bg (face-background face frame 'default))
(box (face-attribute face :box frame 'default))
(inv (face-inverse-video-p face frame 'default)))
(let ((fg (if inv bg fg))
(bg (if inv fg bg)))
(list (wmii-normalize-color frame fg wmii-unspecified-fg)
(wmii-normalize-color frame bg wmii-unspecified-bg)
(wmii-normalize-color frame
(cond
((equal box nil) bg)
((equal box t) fg)
((stringp box) box)
((listp box) (or (plist-get box :color) fg)))
wmii-unspecified-box)))))
(defun wmii-theme (&optional frame)
"Dump the current Emacs theme as a WMII theme."
(concat
"WMII_BACKGROUND='" (car (wmii-face2triplet 'default frame)) "'\n"
"WMII_NORMCOLORS='" (string-join (wmii-face2triplet 'mode-line-inactive frame) " ") "'\n"
"WMII_FOCUSCOLORS='" (string-join (wmii-face2triplet 'mode-line frame) " ") "'\n"
"WMII_URGENTCOLORS='" (string-join (wmii-face2triplet 'mode-line-highlight frame) " ") "'\n"))
(defun wmii-theme-for-display (display)
(let ((frame (make-frame-on-display display)))
(let ((theme (wmii-theme frame)))
(delete-frame frame)
theme)))
|