forked from themix-project/themix-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_color.sh
executable file
·168 lines (144 loc) · 4.31 KB
/
change_color.sh
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
set -ue
SRC_PATH=$(readlink -e $(dirname $0))
darker () {
"${SRC_PATH}/scripts/darker.sh" $@
}
mix () {
"${SRC_PATH}/scripts/mix.sh" $@
}
print_usage() {
echo "usage: $0 [-o OUTPUT_THEME_NAME] [-p PATH_LIST] [-m MAKE_OPTS] PRESET_NAME_OR_PATH"
echo "examples:"
echo " $0 monovedek"
echo " $0 -o my-theme-name ./colors/retro/twg"
echo " $0 -o oomox-gnome-noble -p \"./gtk-2.0 ./gtk-3.0 ./gtk-3.20 ./Makefile\" gnome-noble"
echo " $0 -o oomox-gnome-noble -p \"./gtk-2.0 ./gtk-3.0 ./gtk-3.20 ./Makefile\" -m gtk320 gnome-noble"
exit 1
}
while [[ $# > 0 ]]
do
case ${1} in
-p|--path-list)
CUSTOM_PATHLIST="${2}"
shift
;;
-o|--output)
OUTPUT_THEME_NAME="${2}"
shift
;;
-m|--make-opts)
MAKE_OPTS="${2}"
shift
;;
*)
if [[ "${1}" == -* ]] || [[ ${THEME-} ]]; then
echo "unknown option ${1}"
print_usage
exit 2
fi
THEME="${1}"
;;
esac
shift
done
if [[ -z "${THEME:-}" ]] ; then
print_usage
fi
PATHLIST=(
'./src/openbox-3/'
'./src/assets/'
'./src/gtk-2.0/'
'./src/gtk-3.0/'
'./src/gtk-3.20/'
'./src/xfwm4/'
'./src/metacity-1/'
'./src/unity/'
'Makefile'
'./src/index.theme'
)
if [ ! -z "${CUSTOM_PATHLIST:-}" ] ; then
IFS=', ' read -r -a PATHLIST <<< "${CUSTOM_PATHLIST:-}"
fi
MAKE_GTK3=0
for FILEPATH in "${PATHLIST[@]}"; do
if [[ ${FILEPATH} == *Makefile* ]] ;then
MAKE_GTK3=1
fi
done
MAKE_OPTS="${MAKE_OPTS-all}"
if [[ ${THEME} == */* ]] || [[ ${THEME} == *.* ]] ; then
source "$THEME"
THEME=$(basename ${THEME})
else
source "$SRC_PATH/colors/$THEME"
fi
HDR_BTN_BG=${HDR_BTN_BG-$BTN_BG}
HDR_BTN_FG=${HDR_BTN_FG-$BTN_FG}
WM_BORDER_FOCUS=${WM_BORDER_FOCUS-$MENU_BG}
WM_BORDER_UNFOCUS=${WM_BORDER_UNFOCUS-$MENU_BG}
GTK3_GENERATE_DARK=$(echo ${GTK3_GENERATE_DARK-True} | tr '[:upper:]' '[:lower:]')
GTK2_HIDPI=$(echo ${GTK2_HIDPI-False} | tr '[:upper:]' '[:lower:]')
SPACING=${SPACING-3}
GRADIENT=${GRADIENT-0}
ROUNDNESS=${ROUNDNESS-2}
ROUNDNESS_GTK2_HIDPI=$(( ${ROUNDNESS} * 2 ))
INACTIVE_FG=$(mix ${FG} ${BG} 0.75)
INACTIVE_MENU_FG=$(mix ${MENU_FG} ${MENU_BG} 0.75)
INACTIVE_TXT_FG=$(mix ${MENU_FG} ${MENU_BG} 0.75)
light_folder_base_fallback="$(darker ${SEL_BG} -10)"
medium_base_fallback="$(darker ${SEL_BG} 37)"
dark_stroke_fallback="$(darker ${SEL_BG} 50)"
ICONS_LIGHT_FOLDER="${ICONS_LIGHT_FOLDER-$light_folder_base_fallback}"
ICONS_LIGHT="${ICONS_LIGHT-$SEL_BG}"
ICONS_MEDIUM="${ICONS_MEDIUM-$medium_base_fallback}"
ICONS_DARK="${ICONS_DARK-$dark_stroke_fallback}"
OUTPUT_THEME_NAME="${OUTPUT_THEME_NAME-oomox-$THEME}"
DEST_PATH="$HOME/.themes/${OUTPUT_THEME_NAME/\//-}"
test "$SRC_PATH" = "$DEST_PATH" && echo "can't do that" && exit 1
rm -r "$DEST_PATH" || true
mkdir -p "$DEST_PATH"
cp -r "$SRC_PATH/src/index.theme" "$DEST_PATH"
for FILEPATH in "${PATHLIST[@]}"; do
cp -r "$SRC_PATH/$FILEPATH" "$DEST_PATH"
done
cd "$DEST_PATH"
for FILEPATH in "${PATHLIST[@]}"; do
find $(echo "${FILEPATH}" | sed 's/src\///g' ) -type f -exec sed -i \
-e 's/%BG%/'"$BG"'/g' \
-e 's/%FG%/'"$FG"'/g' \
-e 's/%SEL_BG%/'"$SEL_BG"'/g' \
-e 's/%SEL_FG%/'"$SEL_FG"'/g' \
-e 's/%TXT_BG%/'"$TXT_BG"'/g' \
-e 's/%TXT_FG%/'"$TXT_FG"'/g' \
-e 's/%MENU_BG%/'"$MENU_BG"'/g' \
-e 's/%MENU_FG%/'"$MENU_FG"'/g' \
-e 's/%BTN_BG%/'"$BTN_BG"'/g' \
-e 's/%BTN_FG%/'"$BTN_FG"'/g' \
-e 's/%HDR_BTN_BG%/'"$HDR_BTN_BG"'/g' \
-e 's/%HDR_BTN_FG%/'"$HDR_BTN_FG"'/g' \
-e 's/%WM_BORDER_FOCUS%/'"$WM_BORDER_FOCUS"'/g' \
-e 's/%WM_BORDER_UNFOCUS%/'"$WM_BORDER_UNFOCUS"'/g' \
-e 's/%ROUNDNESS%/'"$ROUNDNESS"'/g' \
-e 's/%ROUNDNESS_GTK2_HIDPI%/'"$ROUNDNESS_GTK2_HIDPI"'/g' \
-e 's/%SPACING%/'"$SPACING"'/g' \
-e 's/%GRADIENT%/'"$GRADIENT"'/g' \
-e 's/%INACTIVE_FG%/'"$INACTIVE_FG"'/g' \
-e 's/%INACTIVE_TXT_FG%/'"$INACTIVE_TXT_FG"'/g' \
-e 's/%INACTIVE_MENU_FG%/'"$INACTIVE_MENU_FG"'/g' \
-e 's/%ICONS_DARK%/'"$ICONS_DARK"'/g' \
-e 's/%ICONS_MEDIUM%/'"$ICONS_MEDIUM"'/g' \
-e 's/%ICONS_LIGHT%/'"$ICONS_LIGHT"'/g' \
-e 's/%ICONS_LIGHT_FOLDER%/'"$ICONS_LIGHT_FOLDER"'/g' \
-e 's/%OUTPUT_THEME_NAME%/'"$OUTPUT_THEME_NAME"'/g' \
{} \; ;
done
if [[ ${GTK3_GENERATE_DARK} != "true" ]] ; then
cp ./gtk-3.0/scss/gtk.scss ./gtk-3.0/scss/gtk-dark.scss || true
cp ./gtk-3.20/scss/gtk.scss ./gtk-3.20/scss/gtk-dark.scss || true
fi
if [[ ${GTK2_HIDPI} == "true" ]] ; then
mv ./gtk-2.0/gtkrc.hidpi ./gtk-2.0/gtkrc
fi
test ${MAKE_GTK3} = 1 && make "${MAKE_OPTS}"
exit 0