exwm
exwm copied to clipboard
Change GTK Themes in EXWM
I would like to create my own function to toggle between light and dark themes. However, I would also like to toggle between GTK themes (adwaita -> adwaita-dark). Hopefully firefox will recognize the GTK theme and also adjust accordingly.
However, i can't find a way to change the GTK Theme outside of gnome. I tried editing the .config/gtk* files, the gsettings and the gtk-chtheme and gtk-theme-swtich packages. Nothing changed my themes for Evince or Nautilus.
I am using Debian experimental with emacs 28.1
Thanks
This can be done without messing with config files by implementing the xsettings protocol: https://specifications.freedesktop.org/xsettings-spec/xsettings-latest.html.
See xsettingsd for a simple implementation.
Interesting. That spec seems approachable. Is that something EXWM should offer? Do you know how does one discover the available settings and their types?
Thanks for the help. I found a solution with gsettings. I think this will only work, if GNOME is installed on the system. Also i found, that all gtk configfiles must be removed. Otherwise gsettings does not seem to work. Even still, this does sometimes not work, for somereasen. I would be happy, if someone could improve this.
I use two different polybar configs, depending on dark or light theme. Thats the purpose of jd/start-panel
;Determin weather to load dark or light theme:
(defun get-current-color-theme ()
(setq check-gnome-color-theme
(string-trim
(substring
(shell-command-to-string "gsettings get org.gnome.desktop.interface color-scheme")
0 -1) "'" "'")))
(defun jd/reload-theme ()
"Refresh the current modus theme"
(interactive)
(get-current-color-theme)
(if (equal check-gnome-color-theme "prefer-dark")
(load-theme 'modus-vivendi)
(load-theme 'modus-operandi))
; jd/start-panel will by itself check weather to load dark or light theme
(if (fboundp 'jd/start-panel)
jd/start-panel))
; load the theme for the first time after starting:
(jd/reload-theme)
(defun toggle-theme ()
"Switch the whole system from dark to light theme or vice versa"
(interactive)
(get-current-color-theme)
(if (equal check-gnome-color-theme "prefer-dark")
(setq dark-state t) (setq dark-state nil))
(if dark-state
(progn
(start-process-shell-command "gsettings" nil "gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'")
(load-theme 'modus-operandi))
(progn
(start-process-shell-command "gsettings" nil "gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'")
(load-theme 'modus-vivendi)))
(jd/start-panel))