Closed goteksc closed 5 years ago
I solved this with the following script:
#!/bin/bash
# colors.css file found in either ~/.config/wpg/formats/ for wpgtk users
# or ~/.cache/wal/ for pywal users
colors_src="$HOME/.config/wpg/formats/colors.css"
rasi_file="$HOME/.config/rofi/globals.rasi"
resources="tp-color0 color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 color10 color11 color12 color13 color14 color15"
for r in $resources; do
if [[ "$r" == "tp-color0" ]]; then
color_tp=$(xrdb -query | awk -v reso=$r '/Rofi\*transparency/{print $2}')
color_var="$(awk '/--color0/{print $2}' $colors_src | tr -d '[=;=]')$color_tp;"
sed -i --follow-symlinks "/$r:/c\\$r: $color_var" "$rasi_file"
elif [[ "$r" != "tp-color0" ]]; then
color_var=$(awk -v reso=$r '$1~reso{print $2}' $colors_src)
sed -i --follow-symlinks "/^$r:/c\\$r: $color_var" "$rasi_file"
fi
done
# regex in awk is to account for font names with spaces e.g: match the second column and any after
fnt=$(xrdb -query | awk '/Rofi\*font1/{ s = ""; for (i = 2; i <= NF; i++) s = s $i " "; print s }')
fntsz=$(xrdb -query | awk '/Rofi\*fontsz1/{print $2}')
sed -i --follow-symlinks "/font01:/c\font01: \"$fnt$fntsz\"\;" "$rasi_file"
Relevant lines from .Xresources
Rofi*font1: DejaVuSansMono Nerd Font Mono
Rofi*fontsz1: 12
! Transparency chart for dummies like me.
! 100% 95% 90% 85% 80% 75% 70% 65% 60% 55% 50% 45% 40% 35% 30% 25% 20% 15% 5% 10% 0%
! FF F2 E6 D9 CC BF B3 A6 99 8C 80 73 66 59 4D 40 33 26 1A 0D 00
Rofi*transparency: D9
Writing to a globals.rasi
file:
* {
tp-color0: #1f1b20D9;
color0: #1f1b20;
color1: #bf4b32;
color2: #5696A7;
color3: #33A4D8;
color4: #2985B3;
color5: #60B5D5;
color6: #5DC7E8;
color7: #c8e1e8;
color8: #39313b;
color9: #ff5731;
color10: #5fcce9;
color11: #30dbff;
color12: #26b1f7;
color13: #68f4ff;
color14: #63ffff;
color15: #ecffff;
font01: "DejaVuSansMono Nerd Font Mono 12";
}
Which is then imported in the first line of the actual theme I use:
@import "globals.rasi"
I'm trying to create a template for a global.rasi file that holds the color values that I'll then import into other rofi themes. But wpgtk won't apply the colors in any .rasi template I try.
Though the template for the old rofi config format that comes with wpgtk, in addition to dunst and i3wm works for me.
globals.rasi
globals.rasi.base