diff options
Diffstat (limited to '.config/wmii-hg/theme-emacs.el')
-rw-r--r-- | .config/wmii-hg/theme-emacs.el | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/.config/wmii-hg/theme-emacs.el b/.config/wmii-hg/theme-emacs.el new file mode 100644 index 0000000..2d74e3b --- /dev/null +++ b/.config/wmii-hg/theme-emacs.el @@ -0,0 +1,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))) |