Skip to content

Instantly share code, notes, and snippets.

@syohex
Created October 1, 2012 14:58
Show Gist options
  • Save syohex/3812290 to your computer and use it in GitHub Desktop.
Save syohex/3812290 to your computer and use it in GitHub Desktop.
capture buffer with all themes
;;; capture-all-theme.el ---
;; Copyright (C) 2012 by Syohei YOSHIDA
;; Author: Syohei YOSHIDA <[email protected]>
;; URL:
;; Version: 0.01
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(eval-when-compile
(require 'cl))
(defun ca-theme:current-window-id ()
(with-temp-buffer
(let ((cmd "xprop -root")
(regexp "_NET_ACTIVE_WINDOW(WINDOW): window id # \\([^,]+\\)"))
(call-process-shell-command cmd nil t)
(goto-char (point-min))
(if (re-search-forward regexp nil t)
(match-string-no-properties 1)
(error "Can't get current window id")))))
(defun ca-theme:load-theme (theme)
(mapc (lambda (th)
(disable-theme th)) custom-enabled-themes)
(load-theme theme t))
(defun capture-all-theme ()
(interactive)
(let ((id (ca-theme:current-window-id)))
(loop for theme in (custom-available-themes)
for output = (format "%s.png" theme)
for cmd = (format "import -frame -window %s %s" id output)
do
(progn
(message "%s" cmd)
(ca-theme:load-theme theme)
(redisplay t)
(call-process-shell-command cmd)
(sleep-for 0.5)))))
;;; capture-all-theme.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment