-
Notifications
You must be signed in to change notification settings - Fork 10
/
generate-theme.sh
executable file
·73 lines (60 loc) · 1.69 KB
/
generate-theme.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
#!/bin/bash
. ~/.cache/wal/colors.sh # import colors from pywal
THEME_NAME="Pywal"
DIR=$(dirname "${BASH_SOURCE[0]}")
THEME_DIR="$DIR/$THEME_NAME"
# Converts hex colors into rgb joined with comma
# #fff -> 255, 255, 255
hexToRgb() {
# Remove '#' character from hex color #fff -> fff
plain=${1#*#}
printf "%d, %d, %d" 0x${plain:0:2} 0x${plain:2:2} 0x${plain:4:2}
}
prepare() {
if [ -d $THEME_DIR ]; then
rm -rf $THEME_DIR
fi
mkdir $THEME_DIR
mkdir "$THEME_DIR/images"
# Copy wallpaper so it can be used in theme
background_image="images/theme_ntp_background_norepeat.png"
cp "$wallpaper" "$THEME_DIR/$background_image"
}
background=$(hexToRgb $background)
foreground=$(hexToRgb $foreground)
accent=$(hexToRgb $color11)
secondary=$(hexToRgb $color8)
generate() {
# Theme template
cat > "$THEME_DIR/manifest.json" << EOF
{
"manifest_version": 3,
"version": "1.0",
"name": "$THEME_NAME Theme",
"theme": {
"images": {
"theme_ntp_background" : "$background_image"
},
"colors": {
"frame": [$background],
"frame_inactive": [$background],
"toolbar": [$accent],
"ntp_text": [$foreground],
"ntp_link": [$accent],
"ntp_section": [$secondary],
"button_background": [$foreground],
"toolbar_button_icon": [$foreground],
"toolbar_text": [$foreground],
"omnibox_background": [$background],
"omnibox_text": [$foreground]
},
"properties": {
"ntp_background_alignment": "bottom"
}
}
}
EOF
}
prepare
generate
echo "Pywal Chrome theme generated at $THEME_DIR"