Skip to content

Instantly share code, notes, and snippets.

@itoshkov
Created December 19, 2018 22:42
Show Gist options
  • Save itoshkov/850c46746705e32e2039fb0112a75ec7 to your computer and use it in GitHub Desktop.
Save itoshkov/850c46746705e32e2039fb0112a75ec7 to your computer and use it in GitHub Desktop.
Change the emacs theme to light or dark variant (GTK+-3)
(defun set-emacs-frames (variant)
(dolist (frame (frame-list))
(let* ((window-id (frame-parameter frame 'outer-window-id))
(id (string-to-number window-id))
(cmd (format "xprop -id 0x%x -f _GTK_THEME_VARIANT 8u -set _GTK_THEME_VARIANT \"%s\""
id variant)))
(call-process-shell-command cmd))))
(defun set-emacs-theme-light ()
(interactive)
(load-theme 'solarized-light t)
(set-emacs-frames "light"))
(defun set-emacs-theme-dark ()
(interactive)
(load-theme 'solarized-dark t)
(set-emacs-frames "dark"))
(if (window-system)
(set-emacs-theme-light))
@itoshkov
Copy link
Author

Is this going to work for Wayland?

In its current version, unlikely. It uses xprop, which is X11 tool. Also the window-id part might not work either. But perhaps it won't be too hard to fix.

I'm still not running Wayland so I haven't tried it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment