From 7c0bd902af20448b716db8c7e757cd4a86b6467f Mon Sep 17 00:00:00 2001 From: Daniel Napora Date: Sun, 20 Aug 2023 09:07:52 +0200 Subject: [PATCH] fonts handling improvements --- bin/colorizer-conky | 91 +++++++++++++++---------- bin/colorizer-ob | 42 ++++++++---- bin/conkyctl | 113 ++++++++++++++++++++++++------- share/mabox-colorizer/fonts.list | 1 + 4 files changed, 173 insertions(+), 74 deletions(-) diff --git a/bin/colorizer-conky b/bin/colorizer-conky index 7002ef3..95aae00 100755 --- a/bin/colorizer-conky +++ b/bin/colorizer-conky @@ -66,13 +66,15 @@ case "$LANG" in COLOR_1="Kolor 1 (większy tekst)" COLOR_2="Kolor 2 (pasek/graf)" BACKGROUND="Kolor tła" - TRANSPARENT="Przezroczyste?" + TRANSPARENT="Przezroczyste tło?" YES="Tak" NO="Nie" FONTS="Czcionka" SELECTFONT="Wybierz czcionkę..." - INCREASE="Powiększ" - DECREASE="Pomniejsz" + FONTFAMILY_LBL="czcionka" + FONTSIZE_LBL="rozmiar czcionki" + INCREASE="Powiększ do" + DECREASE="Pomniejsz do" OLINE="Obrys" SHADOW="Cień" DRAW="Rysuj" @@ -109,13 +111,15 @@ case "$LANG" in COLOR_1="Color 1 (bigger text)" COLOR_2="Color 2 (bars/graphs)" BACKGROUND="Background color" - TRANSPARENT="Transparent?" + TRANSPARENT="Transparent background?" YES="Yes" NO="No" FONTS="Font" SELECTFONT="Select Font..." - INCREASE="Increase" - DECREASE="Decrease" + FONTFAMILY_LBL="font family" + FONTSIZE_LBL="font size" + INCREASE="Increase to" + DECREASE="Decrease to" OLINE="Outline" SHADOW="Shadow" DRAW="Draw" @@ -160,7 +164,7 @@ getvalues () { read STIP <<< "$(grep stippled_borders ${BASECONKY} | cut -d'=' -f2 | cut -d"," -f1)" } -if pgrep -af "conky.*mbcolor" >/dev/null; then +if pgrep -u $USER -af "conky.*mbcolor" >/dev/null; then getvalues [[ "$WINTRANS" == false ]] && BG="bgcolor='$WINCLR'" || BG="" @@ -176,7 +180,7 @@ if pgrep -af "conky.*mbcolor" >/dev/null; then #done < <(pgrep -af "conky.*mbcolor") # array with running conkies - only filenames with full path - readarray -t running < <(pgrep -af "conky -c " | cut -d' ' -f4) + readarray -t running < <(pgrep -u $USER -af "conky -c " | cut -d' ' -f4) #array with all conkies found #for i in "$CONKYDIR"/*.con* "$CONKYDIR"/**/*.con*; do @@ -262,7 +266,7 @@ if pgrep -af "conky.*mbcolor" >/dev/null; then else out+=(" transparent $BACKGROUND,^pipe(mbclr '$WINCLR' conkyctl win_bgcolor_all '${BACKGROUND}' '$me')") fi - out+=("$TRANSPARENT [ $WINTRANS ],^checkout(trans)") + [[ "$WINTRANS" == false ]] && out+=("󰄱 $TRANSPARENT,conkyctl transparent_all true;$me") || out+=("󰄲 $TRANSPARENT,conkyctl transparent_all false;$me") out+=("^sep()") @@ -271,10 +275,6 @@ if pgrep -af "conky.*mbcolor" >/dev/null; then out+=(" AbCd $COLOR_1,^pipe(mbclr '$CLR1' conkyctl color1_all '${COLOR_1}' '$me')") out+=(" AbCd $COLOR_2,^pipe(mbclr '$CLR2' conkyctl color2_all '${COLOR_2}' '$me')") #out+=("^sep()") - out2+=("^tag(trans)") - out2+=("^sep($TRANSPARENT)") - out2+=("$YES,conkyctl transparent_all true;$me") - out2+=("$NO,conkyctl transparent_all false;$me") out+=("^sep()") out+=(" $REGENERATE,^checkout(regenconky)") @@ -296,36 +296,55 @@ if pgrep -af "conky.*mbcolor" >/dev/null; then out+=("^sep()") - out+=("$FONTS [ $FONT $FONTSIZE ],^checkout(font)") + out+=("󰛖 $FONTS [ $FONT $FONTSIZE ],^checkout(font)") out2+=("^tag(font)") out2+=("^sep($FONTS)") - out2+=("$SELECTFONT,mb-setfont conky_all;$me") - out2+=("^sep()") - out2+=("++ $INCREASE,conkyctl basefont_inc_all;$me") - out2+=("-- $DECREASE,conkyctl basefont_dec_all;$me") - out+=("$OLINE/$SHADOW [ $SHADOWS ],^checkout(outline)") - out2+=("^tag(outline)") - out2+=("^sep($DRAW $OLINE/$SHADOW?)") - out2+=("$NO,conkyctl shades_all no;$me") - out2+=("^sep()") - out2+=("$DRAW $SHADOW,conkyctl shades_all shadow;$me") - out2+=("$DRAW $OLINE,conkyctl shades_all outline;$me") - - + out2+=("󰛖 $SELECTFONT [ $FONT $FONTSIZE ],mb-setfont conky_all;$me") + + if [ -f "$HOME/.config/mabox/fonts.list" ];then + mapfile -t favfonts < <( grep -vE "^($|#)" ~/.config/mabox/fonts.list) + else + mapfile -t favfonts < <( grep -vE "^($|#)" /usr/share/mabox-colorizer/fonts.list) + cp /usr/share/mabox-colorizer/fonts.list ~/.config/mabox/ + fi + #notify-send.sh "Ile" "${#favfonts[@]}" + if [ "${#favfonts[@]}" -gt 0 ];then + out2+=("^sep($FONTFAMILY_LBL)") + for fon in "${favfonts[@]}";do + [[ "$FONT" == "$fon" ]] && out2+=(" ${fon},$me") || out2+=(" ${fon},conkyctl basefont_family_all \"${fon}\";$me") + done + fi + out2+=("^sep()") + out2+=(" Edit favorited fonts list,geany ~/.config/mabox/fonts.list") + out2+=("^sep($FONTSIZE_LBL)") + out2+=("󰧴 $INCREASE $((FONTSIZE+1)) px,conkyctl basefont_inc_all;$me") + out2+=("󰧳 $DECREASE $((FONTSIZE-1)) px,conkyctl basefont_dec_all;$me") + out2+=("^sep()") + sizes=(14 13 12 11 10 9 8 7 6) + for i in "${sizes[@]}" + do + [[ "$FONTSIZE" == "$i" ]] && out2+=(" $i px,conkyctl basefont_size_all $i;$me") || out2+=(" $i px,conkyctl basefont_size_all $i;$me") + done + + [[ "$SHADOWS" == "shadow" ]] && out+=("󰄲 $SHADOW,conkyctl shades_all no;$me") || out+=("󰄱 $SHADOW,conkyctl shades_all shadow;$me") + [[ "$SHADOWS" == "outline" ]] && out+=("󰄲 $OLINE,conkyctl shades_all no;$me") || out+=("󰄱 $OLINE,conkyctl shades_all outline;$me") out+=("^sep()") - out+=("$BORDERS [ $BORD $STIP ],^checkout(border)") + + [[ "$BORD" == false ]] && out+=("󰄱 $BORDERS [ $STIP ],^checkout(border)") || out+=("󰄲 $BORDERS [ $STIP ],^checkout(border)") + out2+=("^tag(border)") out2+=("^sep($DRAW $BORDERS?)") - out2+=("$YES,conkyctl draw_borders_all true;$me") - out2+=("$NO,conkyctl draw_borders_all false;$me") + [[ "$BORD" == false ]] && out2+=(" $YES,conkyctl draw_borders_all true;$me") || out2+=(" $YES,conkyctl draw_borders_all false;$me") + [[ "$BORD" == false ]] && out2+=(" $NO,conkyctl draw_borders_all true;$me") || out2+=(" $NO,conkyctl draw_borders_all false;$me") + out2+=("^sep($STIPPLED_BORDERS?)") - out2+=("0 ($SOLID_LINE),conkyctl stippled_borders_all 0;$me") + [[ "$STIP" == 0 ]] && out2+=(" 0 ($SOLID_LINE),conkyctl stippled_borders_all 0;$me") || out2+=(" 0 ($SOLID_LINE),conkyctl stippled_borders_all 0;$me") out2+=("^sep()") - out2+=("1,conkyctl stippled_borders_all 1;$me") - out2+=("2,conkyctl stippled_borders_all 2;$me") - out2+=("3,conkyctl stippled_borders_all 3;$me") - out2+=("4,conkyctl stippled_borders_all 4;$me") - + [[ "$STIP" == 1 ]] && out2+=(" 1 px,conkyctl stippled_borders_all 1;$me") || out2+=(" 1 px,conkyctl stippled_borders_all 1;$me") + [[ "$STIP" == 2 ]] && out2+=(" 2 px,conkyctl stippled_borders_all 2;$me") || out2+=(" 2 px,conkyctl stippled_borders_all 2;$me") + [[ "$STIP" == 3 ]] && out2+=(" 3 px,conkyctl stippled_borders_all 3;$me") || out2+=(" 3 px,conkyctl stippled_borders_all 3;$me") + [[ "$STIP" == 4 ]] && out2+=(" 4 px,conkyctl stippled_borders_all 4;$me") || out2+=(" 4 px,conkyctl stippled_borders_all 4;$me") + out+=("^sep($RESET)") out+=("󰁯 $RESETCOLORS,^checkout(resetcolors)") diff --git a/bin/colorizer-ob b/bin/colorizer-ob index 9728aed..a8b243d 100755 --- a/bin/colorizer-ob +++ b/bin/colorizer-ob @@ -320,16 +320,25 @@ out2+=(" inactive title out2+=("^sep($TITLEBAR_FONT)") out2+=("$FONT... [ ${FNAME} ${FSIZE} ],mb-setfont obtitle;$me") out2+=("^sep(font family)") -fonts=("Noto Sans" "DejaVu Serif" "Roboto Light" "Inconsolata" "Ubuntu" "Source Code Pro") -for i in "${fonts[@]}" -do -[[ "$FNAME" == "$i" ]] && out2+=(" $i,$me") || out2+=(" $i,obtctl fontfamily \"${i}\";$me") -done + +if [ -f "$HOME/.config/mabox/fonts.list" ];then + mapfile -t favfonts < <( grep -vE "^($|#)" ~/.config/mabox/fonts.list) +else + mapfile -t favfonts < <( grep -vE "^($|#)" /usr/share/mabox-colorizer/fonts.list) + cp /usr/share/mabox-colorizer/fonts.list ~/.config/mabox/ +fi +if [ "${#favfonts[@]}" -gt 0 ];then + for fon in "${favfonts[@]}";do + [[ "${FNAME}" == "$fon" ]] && out2+=(" ${fon},$me") || out2+=(" ${fon},obtctl fontfamily \"${fon}\";$me") + done +fi + + out2+=("^sep()") [[ "$WEIGHT" =~ .*"old" ]] && out2+=(" $BOLD,obtctl fontweight Normal;$me") || out2+=(" $BOLD,obtctl fontweight Bold;$me") [[ "$SLANT" =~ .*"talic" ]] && out2+=(" $ITALIC,obtctl fontslant Normal;$me") || out2+=(" $ITALIC,obtctl fontslant Italic;$me") out2+=("^sep($FONTSIZE)") -sizes=(8 9 10 11 12 13 14 15 16) +sizes=(16 15 14 13 12 11 10 9 8) for i in "${sizes[@]}" do [[ "$FSIZE" == "$i" ]] && out2+=(" $i px,obtctl fontsize $i;$me") || out2+=(" $i px,obtctl fontsize $i;$me") @@ -438,11 +447,20 @@ out+=("$SWITCH_TO_MBCOLORS,obtctl theme MBcolors;$me") out+=("^sep($TITLEBAR_FONT)") out+=("$FONT... [ ${FNAME} ${FSIZE} ],mb-setfont obtitle;$me") out+=("^sep(font family)") -fonts=("Noto Sans" "DejaVu Serif" "Roboto Light" "Inconsolata" "Ubuntu" "Source Code Pro") -for i in "${fonts[@]}" -do -[[ "$FNAME" == "$i" ]] && out+=(" $i,$me") || out+=(" $i,obtctl fontfamily \"${i}\";$me") -done + + +if [ -f "$HOME/.config/mabox/fonts.list" ];then + mapfile -t favfonts < <( grep -vE "^($|#)" ~/.config/mabox/fonts.list) +else + mapfile -t favfonts < <( grep -vE "^($|#)" /usr/share/mabox-colorizer/fonts.list) + cp /usr/share/mabox-colorizer/fonts.list ~/.config/mabox/ +fi +if [ "${#favfonts[@]}" -gt 0 ];then + for fon in "${favfonts[@]}";do + [[ "${FNAME}" == "$fon" ]] && out+=(" ${fon},$me") || out+=(" ${fon},obtctl fontfamily \"${fon}\";$me") + done +fi + out+=("^sep()") [[ "$WEIGHT" =~ .*"old" ]] && out+=(" $BOLD,obtctl fontweight Normal;$me") || out+=(" $BOLD,obtctl fontweight Bold;$me") [[ "$SLANT" =~ .*"talic" ]] && out+=(" $ITALIC,obtctl fontslant Normal;$me") || out+=(" $ITALIC,obtctl fontslant Italic;$me") @@ -450,7 +468,7 @@ out+=("^sep()") out+=("$FONTSIZE [ $FSIZE px ],^checkout(obfsize)") out2+=("^tag(obfsize)") out2+=("^sep($FONTSIZE)") -sizes=(8 9 10 11 12 13 14 15 16) +sizes=(16 15 14 13 12 11 10 9 8) for i in "${sizes[@]}" do [[ "$FSIZE" == "$i" ]] && out2+=(" $i px,obtctl fontsize $i;$me") || out2+=(" $i px,obtctl fontsize $i;$me") diff --git a/bin/conkyctl b/bin/conkyctl index 1982dce..1ecba18 100755 --- a/bin/conkyctl +++ b/bin/conkyctl @@ -18,7 +18,7 @@ update_session () { while read -r pid b c confpath do echo "$b $c ${confpath} & sleep .5" >> ${SESSIONFILE} - done < <(pgrep -af "conky -c ") + done < <(pgrep -u $USER -af "conky -c ") # Remove duplicates awk -i inplace '!seen[$0]++' ${SESSIONFILE} } @@ -109,6 +109,30 @@ basefont_dec () { ((FONTSIZE--)) sd "font .*=.*,$" "font = '${FONT}:size=${FONTSIZE}'," ${1} } +basefont_family () { + read FONTDEF <<< "$(grep "font .*=.*,$" ${1} | cut -d'=' -f2,3 |cut -d"'" -f2)" + FONT=${FONTDEF%:*} + FONTSIZE=${FONTDEF#*=} + sd "font .*=.*,$" "font = '${2}:size=${FONTSIZE}'," ${1} +} +basefont_family_all () { + read FONTDEF <<< "$(grep "font .*=.*,$" ${BASECONKY} | cut -d'=' -f2,3 |cut -d"'" -f2)" + FONT=${FONTDEF%:*} + FONTSIZE=${FONTDEF#*=} + sd "font .*=.*,$" "font = '${1}:size=${FONTSIZE}'," ${CONKYDIR}/*mbcolor.conkyrc +} +basefont_size () { + read FONTDEF <<< "$(grep "font .*=.*,$" ${1} | cut -d'=' -f2,3 |cut -d"'" -f2)" + FONT=${FONTDEF%:*} + FONTSIZE=${FONTDEF#*=} + sd "font .*=.*,$" "font = '${FONT}:size=${2}'," ${1} +} +basefont_size_all () { + read FONTDEF <<< "$(grep "font .*=.*,$" ${BASECONKY} | cut -d'=' -f2,3 |cut -d"'" -f2)" + FONT=${FONTDEF%:*} + FONTSIZE=${FONTDEF#*=} + sd "font .*=.*,$" "font = '${FONT}:size=${1}'," ${CONKYDIR}/*mbcolor.conkyrc +} shades_all () { case "$1" in shadow) @@ -242,7 +266,7 @@ startone () { } startall () { for i in "$CONKYDIR"/*_mbcolor*; do - if pgrep -af "conky .*${i}" >/dev/null; then + if pgrep -u $USER -af "conky .*${i}" >/dev/null; then : else conky -c "${i}" & @@ -388,8 +412,10 @@ languages () { NO="Nie" FONTS="Czcionka" SELECTFONT="Wybierz czcionkę..." - INCREASE="Powiększ" - DECREASE="Pomniejsz" + FONTFAMILY_LBL="czcionka" + FONTSIZE_LBL="rozmiar czcionki" + INCREASE="Powiększ do" + DECREASE="Pomniejsz do" OLINE="Obrys" SHADOW="Cień" DRAW="Rysuj" @@ -448,8 +474,10 @@ languages () { NO="No" FONTS="Font" SELECTFONT="Select Font..." - INCREASE="Increase" - DECREASE="Decrease" + FONTFAMILY_LBL="font family" + FONTSIZE_LBL="font size" + INCREASE="Increase to" + DECREASE="Decrease to" OLINE="Outline" SHADOW="Shadow" DRAW="Draw" @@ -508,8 +536,10 @@ languages () { NO="No" FONTS="Font" SELECTFONT="Select Font..." - INCREASE="Increase" - DECREASE="Decrease" + FONTFAMILY_LBL="font family" + FONTSIZE_LBL="font size" + INCREASE="Increase to" + DECREASE="Decrease to" OLINE="Outline" SHADOW="Shadow" DRAW="Draw" @@ -671,19 +701,16 @@ if [[ "$OLD_SYNTAX" = "true" ]];then fi out+=("^sep($COLORS)") - - - [[ "$WINTRANS" == false ]] && out+=("󰄱 $TRANSPARENT,conkyctl transparent true ${1}") || out+=("󰄲 $TRANSPARENT,conkyctl transparent false ${1}") - + if [[ "$WINCLR" != "#" ]];then if [ "$WINTRANS" == false ];then out+=(" AbCd $BACKGROUND,^pipe(mbclr '$WINCLR' conkyctl win_bgcolor '${BACKGROUND}' '$me' ${1})") - out+=("^sep()") else out+=(" transparent $BACKGROUND,^pipe(mbclr '$WINCLR' conkyctl win_bgcolor '${BACKGROUND}' '$me' ${1})") - out+=("^sep()") fi fi + [[ "$WINTRANS" == false ]] && out+=("󰄱 $TRANSPARENT,conkyctl transparent true ${1}") || out+=("󰄲 $TRANSPARENT,conkyctl transparent false ${1}") + out+=("^sep()") if [[ "$1" != *"logo_mbcolor"* ]]; then @@ -733,23 +760,53 @@ if [[ "$OLD_SYNTAX" = "true" ]];then if [[ "$1" != *"logo_mbcolor"* ]]; then if [[ "$1" != *"quoter_mbcolor"* ]]; then - out+=("$FONTS [ $FONT $FONTSIZE ],^checkout(fontsingle)") + out+=("󰛖 $FONTS [ $FONT $FONTSIZE ],^checkout(fontsingle)") out2+=("^tag(fontsingle)") out2+=("^sep($FONTS)") - - out2+=("$SELECTFONT,mb-setfont conky_single ${1};$me") - out2+=("^sep()") - out2+=("++ $INCREASE,conkyctl basefont_inc ${1};$me") - out2+=("-- $DECREASE,conkyctl basefont_dec ${1};$me") + out2+=("󰛖 $SELECTFONT [ $FONT $FONTSIZE ],mb-setfont conky_single ${1};$me") + + + if [ -f "$HOME/.config/mabox/fonts.list" ];then + mapfile -t favfonts < <( grep -vE "^($|#)" ~/.config/mabox/fonts.list) + else + mapfile -t favfonts < <( grep -vE "^($|#)" /usr/share/mabox-colorizer/fonts.list) + cp /usr/share/mabox-colorizer/fonts.list ~/.config/mabox/ + fi + #notify-send.sh "Ile" "${#favfonts[@]}" + if [ "${#favfonts[@]}" -gt 0 ];then + out2+=("^sep($FONTFAMILY_LBL)") + for fon in "${favfonts[@]}";do + [[ "$FONT" == "$fon" ]] && out2+=(" ${fon},$me") || out2+=(" ${fon},conkyctl basefont_family ${1} \"${fon}\";$me") + done fi - out+=("$OLINE/$SHADOW [ $SHADOWS ],^checkout(outline2)") - out2+=("^tag(outline2)") - out2+=("^sep($DRAW $OLINE/$SHADOW?)") - out2+=("$NO,conkyctl shades no ${1};$me") out2+=("^sep()") - out2+=("$DRAW $SHADOW,conkyctl shades shadow ${1};$me") - out2+=("$DRAW $OLINE,conkyctl shades outline ${1};$me") + out2+=(" Edit favorited fonts list,geany ~/.config/mabox/fonts.list") + out2+=("^sep($FONTSIZE_LBL)") + out2+=("󰧴 $INCREASE $((FONTSIZE+1)) px,conkyctl basefont_inc ${1};$me") + out2+=("󰧳 $DECREASE $((FONTSIZE-1)) px,conkyctl basefont_dec ${1};$me") + out2+=("^sep()") + sizes=(14 13 12 11 10 9 8 7 6) + for i in "${sizes[@]}" + do + [[ "$FONTSIZE" == "$i" ]] && out2+=(" $i px,conkyctl basefont_size ${1} $i;$me") || out2+=(" $i px,conkyctl basefont_size ${1} $i;$me") + done + + + fi + + + + [[ "$SHADOWS" == "shadow" ]] && out+=("󰄲 $SHADOW,conkyctl shades no ${1};$me") || out+=("󰄱 $SHADOW,conkyctl shades shadow ${1};$me") + [[ "$SHADOWS" == "outline" ]] && out+=("󰄲 $OLINE,conkyctl shades no ${1};$me") || out+=("󰄱 $OLINE,conkyctl shades outline ${1};$me") out+=("^sep()") + #out+=("$OLINE/$SHADOW [ $SHADOWS ],^checkout(outline2)") + #out2+=("^tag(outline2)") + #out2+=("^sep($DRAW $OLINE/$SHADOW?)") + #out2+=("$NO,conkyctl shades no ${1};$me") + #out2+=("^sep()") + #out2+=("$DRAW $SHADOW,conkyctl shades shadow ${1};$me") + #out2+=("$DRAW $OLINE,conkyctl shades outline ${1};$me") + #out+=("^sep()") fi [[ "$BORD" == false ]] && out+=("󰄱 $BORDERS [ $STIP ],^checkout(bordersingle)") || out+=("󰄲 $BORDERS [ $STIP ],^checkout(bordersingle)") out2+=("^tag(bordersingle)") @@ -1209,6 +1266,10 @@ case "$1" in basefont_dec_all) basefont_dec_all;; basefont_inc) basefont_inc "$2";; basefont_dec) basefont_dec "$2";; + basefont_family) basefont_family "$2" "$3";; + basefont_family_all) basefont_family_all "$2";; + basefont_size) basefont_size "$2" "$3";; + basefont_size_all) basefont_size_all "$2";; setfont_all) setfont_all;; serfont) setfont;; shades_all) shades_all "$2";; diff --git a/share/mabox-colorizer/fonts.list b/share/mabox-colorizer/fonts.list index a911dd4..c4549e0 100644 --- a/share/mabox-colorizer/fonts.list +++ b/share/mabox-colorizer/fonts.list @@ -8,3 +8,4 @@ Noto Sans Roboto Ubuntu Noto Sans Light +Source Code Pro