44 lines
1 KiB
Clojure
Executable file
44 lines
1 KiB
Clojure
Executable file
#!/usr/bin/env bb
|
|
(ns toggle-theme
|
|
"Script to toggle between light and dark themes. Inspired by
|
|
https://github.com/pedrocr/dotfiles/blob/master/.config/sway/envsetup."
|
|
(:require [clojure.java.shell :refer [sh]]))
|
|
|
|
(def themes
|
|
{:emacs
|
|
{:dark "doom-solarized-dark-high-contrast"
|
|
:light "doom-solarized-light"}
|
|
:gnome
|
|
{:dark "Adwaita-dark"
|
|
:light "Adwaita"}})
|
|
|
|
(def theme-preferences
|
|
["gtk"
|
|
"icon"
|
|
"cursor"])
|
|
|
|
(defn current-theme
|
|
[]
|
|
(if (re-find #"dark" (:out (sh "gsettings" "get" "org.gnome.desktop.interface" "gtk-theme")))
|
|
:dark
|
|
:light))
|
|
|
|
(defn next-theme
|
|
[]
|
|
(if (= :dark (current-theme))
|
|
:light
|
|
:dark))
|
|
|
|
(case (some->> *command-line-args*
|
|
first)
|
|
"get" (println (name (current-theme)))
|
|
|
|
"switch"
|
|
(let [switch-to (next-theme)
|
|
gnome-theme ((:gnome themes) switch-to)]
|
|
(run!
|
|
#(sh "gsettings" "set" "org.gnome.desktop.interface" (str % "-theme") gnome-theme)
|
|
theme-preferences)
|
|
|
|
(sh "emacsclient" "-e" (str "(load-theme '" ((:emacs themes) switch-to) ")"))
|
|
nil))
|