-
Notifications
You must be signed in to change notification settings - Fork 5
/
generate.sh
executable file
·40 lines (31 loc) · 1009 Bytes
/
generate.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
#!/bin/sh
# Generate *.qbtheme file from Xresources.
# This is a qBittorrent theme generator.
# https://github.com/mahdimirzade/qbittorrent
TARGET=${1:-example.qbtheme}
generate_theme() {
XRES=${HOME}/.Xresources
SRC=$1
DST=$2
[ -f "${DST}.tmp" ] && rm "${DST}.tmp"
cp "${SRC}" "${DST}.tmp"
CLBG=$(awk "/background/ {print \$2;exit}" "$XRES")
CLFG=$(awk "/foreground/ {print \$2;exit}" "$XRES")
CLCR=$(awk "/cursorColor/ {print \$2;exit}" "$XRES")
sed "s|%clbg%|$CLBG|g" "$DST".tmp > "$DST"
mv "$DST" "$DST".tmp
sed "s|%clfg%|$CLFG|g" "$DST".tmp > "$DST"
mv "$DST" "$DST".tmp
sed "s|%clcr%|$CLCR|g" "$DST".tmp > "$DST"
mv "$DST" "$DST".tmp
for i in $(seq 0 15); do
VALUE=$(awk "/color$i/ {print \$2;exit}" "$XRES")
sed "s|%cl${i}%|$VALUE|g" "$DST".tmp > "$DST"
mv "$DST" "$DST".tmp
done
[ -f "${DST}" ] && rm "${DST}"
mv "${DST}.tmp" "${DST}"
}
generate_theme config.json.in config.json
generate_theme stylesheet.qss.in stylesheet.qss
rcc resources.qrc -o "$TARGET" -binary