summaryrefslogtreecommitdiffstats
path: root/.local/bin
diff options
context:
space:
mode:
authorAmin Bandali <bandali@gnu.org>2021-10-19 00:36:37 -0400
committerAmin Bandali <bandali@gnu.org>2021-10-19 00:36:37 -0400
commit298f42fef8c1cb876c6596cbca3920a549a9a6d0 (patch)
treefa4b4754c2bcb1094898541f569b46d55e55f5d3 /.local/bin
parent7dd9938023b620a4e65b57a50d5414ac577abf0c (diff)
downloadconfigs-298f42fef8c1cb876c6596cbca3920a549a9a6d0.tar.gz
configs-298f42fef8c1cb876c6596cbca3920a549a9a6d0.tar.xz
configs-298f42fef8c1cb876c6596cbca3920a549a9a6d0.zip
add change-theme script
allows changing themes for future application instances as well as currently-running ones on the fly. xterm and emacs have been tested and are known to work so far.
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/change-theme30
1 files changed, 30 insertions, 0 deletions
diff --git a/.local/bin/change-theme b/.local/bin/change-theme
new file mode 100755
index 0000000..5d997cd
--- /dev/null
+++ b/.local/bin/change-theme
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+dark_color='black' # #222
+light_color='white'
+
+if [ "$1" = "dark" ]; then
+ fg="$light_color"
+ bg="$dark_color"
+elif [ "$1" = "light" ]; then
+ fg="$dark_color"
+ bg="$light_color"
+else
+ echo "Usage: $0 {dark|light}"
+ exit 1
+fi
+
+# most applications using xresources
+printf "*.foreground: $fg\n*.background: $bg" | xrdb -override
+# xterm, basically
+printf "*VT100*foreground: $fg\n*VT100*background: $bg" | xrdb -override
+
+# emacs
+emacsclient -ue "(set-face-attribute 'default nil :foreground \"$fg\" :background \"$bg\")"
+# terminals
+for term in /dev/pts/*; do
+ if [ -w "$term" ]; then
+ printf "\033]10;$fg\a" > "$term"
+ printf "\033]11;$bg\a" > "$term"
+ fi
+done