summaryrefslogtreecommitdiff
path: root/scripts/.local/bin/colorset
blob: 38eb44c57ce01faea616f7d986efb7f06496eb37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

if [ -f /usr/bin/wal ]; then
	/usr/bin/wal -i "$1"
else
	wal -i "$1"
fi

# Checking for non-existant dirs
! [ -f "$SUCK"/colors/dmenu ] && mkdir -p "$SUCK"/colors/dmenu
! [ -f "$SUCK"/colors/dwm ] && mkdir -p "$SUCK"/colors/dwm
! [ -f "$SUCK"/colors/neovimb/src ] && mkdir -p "$SUCK"/colors/neovimb/src
! [ -f "$SUCK"/colors/st ] && mkdir -p "$SUCK"/colors/st

# Purging previous colorscheme files
convert "$1" "$SUCK"/colors/wallpaper.png

# Setting the new colorscheme based on the wallpaper and making some color tweaks
cp -rf ~/.cache/wal/colors-wal-dmenu.h "$SUCK"/colors/dmenu/colors.h
cp -rf ~/.cache/wal/colors-wal-st.h "$SUCK"/colors/st/colors.h
head -7 ~/.cache/wal/colors-wal-dwm.h > "$SUCK"/colors/dwm/colors.h
sed -i s/"$(grep norm_border "$SUCK"/colors/dwm/colors.h | cut -d# -f 2 | cut -d\" -f 1)"/"$(grep black "$SUCK"/colors/st/colors.h | head -1 | cut -d# -f 2 | cut -d\" -f 1)"/g "$SUCK"/colors/dwm/colors.h

###
cp -rf "$XDG_CONFIG_HOME"/neovimb/config.h "$SUCK"/colors/neovimb/src/
###
OLDSTRING=$(grep SETTING_INPUT_CSS "$SUCK"/colors/neovimb/src/config.h)
NEWSTRING="#define SETTING_INPUT_CSS                     \"background-color:$(head -2 "$SUCK"/colors/dwm/colors.h | grep bg | cut -d\" -f2);color:$(head -2 "$SUCK"/colors/dwm/colors.h | grep fg | cut -d\" -f2);font:\" SETTING_GUI_FONT_NORMAL"
sed -i s."$OLDSTRING"."$NEWSTRING".g "$SUCK"/colors/neovimb/src/config.h
###
OLDSTRING=$(grep SETTING_STATUS_CSS "$SUCK"/colors/neovimb/src/config.h)
NEWSTRING="#define SETTING_STATUS_CSS                    \"color:$(tail -3 "$SUCK"/colors/dwm/colors.h | grep fg | cut -d\" -f2);background-color:$(tail -3 "$SUCK"/colors/dwm/colors.h | grep bg | cut -d\" -f2);font:\" SETTING_GUI_FONT_EMPH"
sed -i s."$OLDSTRING"."$NEWSTRING".g "$SUCK"/colors/neovimb/src/config.h
###
OLDSTRING=$(grep SETTING_STATUS_SSL_CSS "$SUCK"/colors/neovimb/src/config.h)
NEWSTRING="#define SETTING_STATUS_SSL_CSS                \"background-color:$(tail -3 "$SUCK"/colors/dwm/colors.h | grep bg | cut -d\" -f2);color:$(tail -3 "$SUCK"/colors/dwm/colors.h | grep fg | cut -d\" -f2);\""
sed -i s."$OLDSTRING"."$NEWSTRING".g "$SUCK"/colors/neovimb/src/config.h

# Recompiling Suckless Programs with new colorscheme
cp -rf "$SUCK"/colors/* "$SUCK"
cp -rf "$SUCK"/colors/wallpaper.png ~/.config/wallpaper

xwallpaper --stretch "$WALLPAPER"
cd "$SUCK"/dwm && git pull ; doas make clean install ; make clean
cd "$SUCK"/dmenu && git pull ; doas make clean install ; make clean
cd "$SUCK"/neovimb && git pull ; doas make clean install ; make clean
cd "$SUCK"/st && git pull ; doas make clean install ; make clean