78 lines
1.8 KiB
Bash

#!/usr/bin/env bash
xfile="$HOME/.Xresources"
theme="$(printf "cyan\nmagenta\ndark\norange\nred" | rofi -dmenu -i -p "Theme" -l 5)"
case "$theme" in
cyan)
bg="#071616"
bunfoc="#353234"
bfoc="#144949"
;;
magenta)
bg="#211019"
bunfoc="#2d060e"
bfoc="#4c1139"
;;
dark)
bg="#0a0200"
bunfoc="#262323"
bfoc="#353131"
;;
orange)
bg="#351909"
bunfoc="#1e0e05"
bfoc="#51250c"
;;
red)
bg="#680e10"
bunfoc="#380a0b"
bfoc="#a31619"
;;
*) exit;;
esac
dselb="$bfoc"
sed -i \
-e "s/\*\.background:.*/\*\.background: $bg/" \
-e "s/\*\.border_unfocused:.*/\*\.border_unfocused: $bunfoc/" \
-e "s/\*\.border_focused:.*/\*\.border_focused: $bfoc/" \
-e "s/dmenu\.selbackground:.*/dmenu\.selbackground: $dselb/" \
$xfile
# get colors
xrdb "$xfile"
fg=$(xrdb -query | awk '/\*.foreground/ { printf $2 }')
bg=$(xrdb -query | awk '/\*.background/ { printf $2 }')
bfoc=$(xrdb -query | awk '/\*.border_focused/ { printf $2 }')
# black=$(xrdb -query | awk '/color0/ { printf $2 }')
# red=$(xrdb -query | awk '/color1:/ { printf $2 }')
# green=$(xrdb -query | awk '/color2/ { printf $2 }')
# yellow=$(xrdb -query | awk '/color3/ { printf $2 }')
# blue=$(xrdb -query | awk '/color4/ { printf $2 }')
# magenta=$(xrdb -query | awk '/color5/ { printf $2 }')
# cyan=$(xrdb -query | awk '/color6/ { printf $2 }')
# white=$(xrdb -query | awk '/color7/ { printf $2 }')
# dunst
sed -i \
-e "s/^\s*foreground.*/ foreground = \"$fg\"/" \
-e "s/^\s*background.*/ background = \"$bg\"/" \
-e "s/^\s*frame_color.*/ frame_color = \"$bfoc\"/" \
~/.config/dunst/dunstrc
# rofi
sed -i \
-e "s/foreground:.*/foreground: ${fg};/" \
-e "s/background:.*/background: ${bg};/" \
-e "s/maincolor:.*/maincolor: ${bfoc};/" \
~/.config/rofi/theme.rasi
bspc wm -r
notify-send "Theme changed!"