#!/bin/bash

# change bar colors in i3 config
sed -i -E '
s/^[[:space:]]*background[[:space:]]+.*/     background #303A6F/g;
s/^[[:space:]]*statusline[[:space:]]+.*/     statusline #F9FAF9/g;
s/^[[:space:]]*separator[[:space:]]+.*/     separator  #454947/g;

s/^[[:space:]]*focused_workspace[[:space:]]+.*/     focused_workspace  #DBDEED #303A6F #DBDEED/g;
s/^[[:space:]]*active_workspace[[:space:]]+.*/     active_workspace   #DBDEED #303A6F #DBDEED/g;
s/^[[:space:]]*inactive_workspace[[:space:]]+.*/     inactive_workspace #303A6F #303A6F #DBDEED/g;
s/^[[:space:]]*urgent_workspace[[:space:]]+.*/     urgent_workspace   #303A6F #4F5370 #1A143A/g;
s/^[[:space:]]*binding_mode[[:space:]]+.*/     binding_mode       #16A085 #2C2C2C #F9FAF9/g;
' "$HOME/.config/i3/config"

# change client colors in i3 config
sed -i -E '
s/^[[:space:]]*client\.focused[[:space:]]+.*/client.focused          #DBDEED #DBDEED #3A3E5B #FDF6E3   #DBDEED/g;
s/^[[:space:]]*client\.focused_inactive[[:space:]]+.*/client.focused_inactive #2F3D44 #1A143A #DBDEED #454948   #2F3D44/g;
s/^[[:space:]]*client\.unfocused[[:space:]]+.*/client.unfocused        #2F3D44 #1A143A #DBDEED #454948   #1A143A/g;
s/^[[:space:]]*client\.urgent[[:space:]]+.*/client.urgent           #CB4B16 #FDF6E3 #1ABC9C #268BD2   #FDF6E3/g;
s/^[[:space:]]*client\.placeholder[[:space:]]+.*/client.placeholder      #000000 #0C0C0C #FFFFFF #000000   #0C0C0C/g;

s/^[[:space:]]*client\.background[[:space:]]+.*/client.background       #2B2C2B/g;
' "$HOME/.config/i3/config"

# change dunst notifications theme
sed -i -E '
22s|.*|    separator_color = "#585858"|;
29s|.*|    color = "#83a598"|;
38s|.*|    background = "#5955E0"|;
39s|.*|    foreground = "#ebdbb2"|;
43s|.*|    background = "#5955E0"|;
44s|.*|    foreground = "#ebdbb2"|;
48s|.*|    background = "#5955E0"|;
49s|.*|    foreground = "#ebdbb2"|;
' "$HOME/.config/dunst/dunstrc"
killall dunst;notify-send theme_updated

# change micro theme
sed -i '2s|.*|    "colorscheme": "geany"|' "$HOME/.config/micro/settings.json"

# change rofi theme
sed -i '1s|.*|@theme "/usr/share/rofi/themes/Indego.rasi"|' "$HOME/.config/rofi/config.rasi"

# change alacritty theme
sed -i '331s/.*/  "~\/.config\/alacritty\/themes\/themes\/msx.toml"/' "$HOME/.config/alacritty/alacritty.toml"

i3 reload
