* .local/bin/change-theme: Only call emacsclient there is an emacs process.
[~bandali/configs] / .local / bin / change-theme
CommitLineData
298f42fe
AB
1#!/bin/sh
2
3dark_color='black' # #222
4light_color='white'
5
6if [ "$1" = "dark" ]; then
7 fg="$light_color"
8 bg="$dark_color"
9elif [ "$1" = "light" ]; then
10 fg="$dark_color"
11 bg="$light_color"
12else
13 echo "Usage: $0 {dark|light}"
14 exit 1
15fi
16
17# most applications using xresources
18printf "*.foreground: $fg\n*.background: $bg" | xrdb -override
19# xterm, basically
20printf "*VT100*foreground: $fg\n*VT100*background: $bg" | xrdb -override
21
22# emacs
e2640242
AB
23if [ "$(pgrep -u $USER emacs)" ]; then
24 emacsclient -ue "(set-face-attribute 'default nil :foreground \"$fg\" :background \"$bg\")"
25fi
298f42fe
AB
26# terminals
27for term in /dev/pts/*; do
28 if [ -w "$term" ]; then
29 printf "\033]10;$fg\a" > "$term"
30 printf "\033]11;$bg\a" > "$term"
31 fi
32done