From 0f7232e2c4b1babe92156b989bc53ab4aa6dd4b7 Mon Sep 17 00:00:00 2001 From: akshay Date: Mon, 7 Feb 2022 10:36:04 +0530 Subject: [PATCH] Colorschemesync for glava,polybar,rofi --- colorscheme.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ glavasync.sh | 7 +++++ 2 files changed, 84 insertions(+) create mode 100755 colorscheme.sh create mode 100755 glavasync.sh diff --git a/colorscheme.sh b/colorscheme.sh new file mode 100755 index 0000000..80e3042 --- /dev/null +++ b/colorscheme.sh @@ -0,0 +1,77 @@ +#! /bin/bash + +# ./colorscheme /path/to/image + +# This script does 4 things. +# => Generate colorscheme with pywal +# => Copy colors to polybar +# => Copy colors to rofi +# => Change the background image path in i3 config +polybarcfg="$HOME/.config/polybar/config" +roficfg="$HOME/.config/rofi/appsmenu.rasi" +powercfg="$HOME/.config/rofi/powermenu/powermenu.rasi" +powerconfirmcfg="$HOME/.config/rofi/powermenu/powermenu-confirm.rasi" +glavacfg="$HOME/.config/glava/bars.glsl" +rofilist=("$powercfg" "$roficfg" "$powerconfirmcfg" ) +if [ -f "$1" ]; then + + # Generate coloerscheme + picture=$(echo $1 | sed 's+~+/home/akshay+') + wal -i $picture + + # Takes the colors from pywal json files in .cache and stores in 3 files glavacolors, polycolors and roficolors + jsonfile="$HOME/.cache/wal/schemes/"$(echo $picture | sed -e "s+/+_+g" -e "s+\.+_+g")"_dark_None_None_1.1.0.json" + cat $jsonfile | grep -E 'color[0-9]' | sed -e "s/ //g" -e 's/"//g' -e "s/:/ = /" -e "s/,//g" > polycolors + cat polycolors | sed -e 's/ =/:/' | sed -e 's/^/ /' | sed -e 's/$/;/' > roficolors + cat polycolors > glavacolors && sed -i 's/ //g' glavacolors + sed -i '1,3d;5,15d;' glavacolors + + cat glavacolors + # Replace glava bars colors + awk -i inplace 'BEGIN{FS=OFS="="} + NR==FNR {color[$1]=$2 ; next } + FNR!=NR && $1 in color {$2=color[$1]} + 1' glavacolors glavasync.sh + ./glavasync.sh $glavacfg + rm glavacolors + + # Copyi/Replace colors from polycolors to ~/.config/polybar/... + if grep -Eq 'color[0-9]' $polybarcfg; then + awk -i inplace 'BEGIN{FS=OFS="="} + NR==FNR {color[$1]=$2 ; next } + FNR!=NR && $1 in color {$2=color[$1]} + 1' polycolors $polybarcfg + else + cp $polybarcfg $polybarcfg.backup + sed -i '/\[colors]/r polycolors' $polybarcfg + fi + rm polycolors + + # Copy/Replace colors from roficolors to ~/.config/rofi/... + # polycolors and roficolrs are created repeatedly as each copy/replace moves the values from file to the config files + for i in "${rofilist[@]}" + do + if grep -Eq ' color[0-9]' $i; then + awk -i inplace 'BEGIN{FS=OFS=": "} + NR==FNR {color[$1]=$2 ; next } + FNR!=NR && $1 in color {$2=color[$1]} + 1' roficolors $i + else + echo "2 here" + cp $i $i.backup + sed -i '/\* {/r roficolors' $i + fi + cat $jsonfile | grep -E 'color[0-9]' | sed -e "s/ //g" -e 's/"//g' -e "s/:/ = /" -e "s/,//g" > polycolors + rm roficolors + cat polycolors | sed -e 's/ =/:/' | sed -e 's/^/ /' | sed -e 's/$/;/' > roficolors + rm polycolors + done + rm roficolors + + # Replace backgroup image path in i3config + cd ~/.config/i3 + awk -v t=$1 '$3 ~ /feh$/ {$5=t}1' config > config.rm + mv config.rm config +else + echo "Image doesnt exist" +fi diff --git a/glavasync.sh b/glavasync.sh new file mode 100755 index 0000000..38924d2 --- /dev/null +++ b/glavasync.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +color15=#ccd9d4 +color3=#628679 + +sed -i '/@fg:mix/d' $1 +echo '#define COLOR @fg:mix('$color15', '$color3', clamp(d / GRADIENT, 0, 1))' >> $1