From 428c723cce6ecf14f3fdad0e74597717d2b228a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Sat, 11 Jun 2022 14:24:24 +0300 Subject: [PATCH] Theming overhaul 1: Chromium theme --- wal_to_chromium.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 wal_to_chromium.sh diff --git a/wal_to_chromium.sh b/wal_to_chromium.sh new file mode 100755 index 0000000..89c71f0 --- /dev/null +++ b/wal_to_chromium.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# +# Apply pywal-generated color palette to Chromium +# code from https://github.com/metafates/ChromiumPywal +# + +. ~/.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"