make it better

This commit is contained in:
Lain
2022-03-28 17:02:21 +03:00
parent dbce46a44a
commit d82082366f
2 changed files with 55 additions and 46 deletions

View File

@@ -11,7 +11,7 @@ Generates [pywal](https://github.com/dylanaraps/pywal) theme for Chromium
3. Go to `chrome://extensions` 3. Go to `chrome://extensions`
4. Turn on "Developer Mode" in the top right corner 4. Turn on "Developer Mode" in the top right corner
5. Press "Load unpacked" 5. Press "Load unpacked"
6. Select "GeneratedTheme" in the same folder with the script 6. Select "Pywal" (by default) in the same folder with the script
7. ??? 7. ???
8. PROFIT! 8. PROFIT!

View File

@@ -1,9 +1,12 @@
#!/bin/bash #!/bin/bash
. ~/.cache/wal/colors.sh . ~/.cache/wal/colors.sh # import colors from pywal
THEME_NAME="Pywal"
DIR=$(dirname "${BASH_SOURCE[0]}") DIR=$(dirname "${BASH_SOURCE[0]}")
THEME_DIR="$DIR/GeneratedTheme" THEME_DIR="$DIR/$THEME_NAME"
# Converts hex colors into rgb joined with comma # Converts hex colors into rgb joined with comma
# #fff -> 255, 255, 255 # #fff -> 255, 255, 255
@@ -13,40 +16,49 @@ hexToRgb() {
printf "%d, %d, %d" 0x${plain:0:2} 0x${plain:2:2} 0x${plain:4:2} printf "%d, %d, %d" 0x${plain:0:2} 0x${plain:2:2} 0x${plain:4:2}
} }
if [ ! -d $THEME_DIR ]; then prepare() {
mkdir $THEME_DIR if [ -d $THEME_DIR ]; then
rm -rf $THEME_DIR
fi fi
if [ ! -d "$THEME_DIR/images" ]; then mkdir $THEME_DIR
mkdir "$THEME_DIR/images" mkdir "$THEME_DIR/images"
fi
# Copy wallpaper so it can be used in theme # Copy wallpaper so it can be used in theme
background_image="images/theme_ntp_background_norepeat.png" background_image="images/theme_ntp_background_norepeat.png"
cp "$wallpaper" "$THEME_DIR/$background_image" cp "$wallpaper" "$THEME_DIR/$background_image"
}
background=$(hexToRgb $background)
foreground=$(hexToRgb $foreground)
accent=$(hexToRgb $color11)
secondary=$(hexToRgb $color8)
generate() {
# Theme template # Theme template
cat > "$THEME_DIR/manifest.json" << EOF cat > "$THEME_DIR/manifest.json" << EOF
{ {
"manifest_version": 3, "manifest_version": 3,
"version": "1.0", "version": "1.0",
"name": "Pywal Theme", "name": "$THEME_NAME Theme",
"theme": { "theme": {
"images": { "images": {
"theme_ntp_background" : "$background_image" "theme_ntp_background" : "$background_image"
}, },
"colors": { "colors": {
"frame": [$(hexToRgb $background)], "frame": [$background],
"frame_inactive": [$(hexToRgb $background)], "frame_inactive": [$background],
"toolbar": [$(hexToRgb $color11)], "toolbar": [$accent],
"ntp_text": [$(hexToRgb $foreground)], "ntp_text": [$foreground],
"ntp_link": [$(hexToRgb $color11)], "ntp_link": [$accent],
"ntp_section": [$(hexToRgb $color8)], "ntp_section": [$secondary)],
"button_background": [$(hexToRgb $foreground)], "button_background": [$foreground],
"toolbar_button_icon": [$(hexToRgb $foreground)], "toolbar_button_icon": [$foreground],
"toolbar_text": [$(hexToRgb $foreground)], "toolbar_text": [$foreground],
"omnibox_background": [$(hexToRgb $background)], "omnibox_background": [$background],
"omnibox_text": [$(hexToRgb $foreground)] "omnibox_text": [$foreground]
}, },
"properties": { "properties": {
"ntp_background_alignment": "bottom" "ntp_background_alignment": "bottom"
@@ -54,11 +66,8 @@ cat > "$THEME_DIR/manifest.json" << EOF
} }
} }
EOF EOF
}
prepare
# Remove cache so chrome will refresh theme colors on restart generate
if [ -f "$THEME_DIR/Cached Theme.pak" ]; then echo "Pywal Chrome theme generated at $THEME_DIR"
rm "$THEME_DIR/Cached Theme.pak"
fi
echo "Theme generated at $THEME_DIR"