[toggle_themes] add Kitty support

This commit is contained in:
Rune Juhl (Atea) 2024-12-02 10:44:30 +01:00
parent 1ba93e4cad
commit ba5efb8223

View file

@ -6,12 +6,13 @@
[babashka.fs :as fs]))
(def themes
{:emacs
{:dark "doom-opera"
:light "doom-oksolar-light"}
:gnome
{:dark "Adwaita-dark"
:light "Adwaita"}})
{:light {:emacs "doom-oksolar-light"
:gnome "Adwaita"
:kitty "doom-oksolar-light"}
:dark {:emacs "doom-opera"
:gnome "Adwaita-dark"
:kitty "Solarized Darcula"}})
(def theme-preferences
["gtk"
@ -36,8 +37,9 @@
"get" (println (name (current-theme)))
"toggle"
(let [switch-to (next-theme)
gnome-theme ((:gnome themes) switch-to)]
(let [next-scheme (next-theme)
next-themes (next-scheme themes)
gnome-theme (:gnome next-themes)]
;; https://askubuntu.com/questions/1464937/inconsistent-dark-theme-for-gtk-apps-on-23-04
;;
;; $ gsettings get org.gnome.desktop.interface color-scheme
@ -50,16 +52,16 @@
;; [["org.gnome.desktop.interface" "gtk-theme"]
;; ["org.gnome.desktop.wm.preferences" "theme"]]
(run!
#(sh "gsettings" "set" "org.gnome.desktop.interface" (str % "-theme") gnome-theme)
theme-preferences)
(sh "gsettings" "set" "org.gnome.desktop.interface" "color-scheme" (str "prefer-" (name (next-theme))))
(sh "gsettings" "set" "org.gnome.desktop.interface" "color-scheme" (str "prefer-" (name next-scheme)))
(sh "gsettings" "set" "org.gnome.desktop.wm.preferences" "theme" gnome-theme)
(run!
#(sh "emacsclient" "--socket-name" % "--eval" (str "(load-theme '" ((:emacs themes) switch-to) ")"))
#(sh "emacsclient" "--socket-name" % "--eval" (str "(load-theme '" (:emacs next-themes) ")"))
(map str (fs/list-dir (fs/file (System/getenv "XDG_RUNTIME_DIR") "emacs"))))
(sh "kitty" "+kitten" "themes" "--reload-in=all" (:kitty next-themes))
nil)
false)