From 07d4274ac38768939f93ce3e9296bcb7410ea951 Mon Sep 17 00:00:00 2001 From: Daniel Napora Date: Tue, 1 Aug 2023 15:03:46 +0200 Subject: [PATCH] handle OB rc.xml font and button layout other OB themes --- bin/colorizer-ob | 125 +++++++++++++++++++++++++++++++---------------- bin/obtctl | 19 ++++--- 2 files changed, 94 insertions(+), 50 deletions(-) diff --git a/bin/colorizer-ob b/bin/colorizer-ob index 705257c..123dd6c 100755 --- a/bin/colorizer-ob +++ b/bin/colorizer-ob @@ -47,6 +47,7 @@ case "$LANG" in INACTIVE_BG="Tło nieaktywnego okna" TITLEBAR_TEXT="Tekst paska tytułowego" FONT="Czcionka" + FONTSIZE="Rozmiar czcionki" BOLD="Pogrubienie" ITALIC="Kursywa" TEXTALIGN="Wyrównanie tytułu" @@ -68,6 +69,8 @@ case "$LANG" in RAISED="uniesiony - raised" SUNKEN="wklęsły - sunken" BUTTONS="Przyciski" + BUTTONS_LAYOUT="Układ przycisków" + LEGEND="Legenda" GRADIENT_TYPE="Typ Gradientu" SOLID_COLOR="Jednolity kolor (brak gradientu)" PRE_GRADIENTS="Gotowe gradienty" @@ -105,6 +108,7 @@ case "$LANG" in TITLEBAR_TEXT="Title Bar Text" TITLEBAR_FONT="Title Bar Font" FONT="Font" + FONTSIZE="Font size" BOLD="Bold" ITALIC="Italic" TEXTALIGN="Title align" @@ -126,6 +130,8 @@ case "$LANG" in RAISED="raised" SUNKEN="sunken" BUTTONS="Buttons" + BUTTONS_LAYOUT="Buttons Layout" + LEGEND="Legend" GRADIENT_TYPE="Gradient type" SPLITVERTICAL="SplitVertical" MIRRORHORIZONTAL="MirrorHorizontal" @@ -154,6 +160,41 @@ case "$LANG" in ;; esac +getvalues () { + read ABG <<< "$(grep .active.title.bg.color: ${THEMERC} | cut -d':' -f2)" + read ABGTO <<< "$(grep .active.title.bg.colorTo ${THEMERC} | cut -d':' -f2)" + read NBG <<< "$(grep .inactive.title.bg.color: ${THEMERC} | cut -d':' -f2)" + read NBGTO <<< "$(grep .inactive.title.bg.colorTo ${THEMERC} | cut -d':' -f2)" + read AFG <<< "$(grep .active.label.text.color ${THEMERC} | cut -d':' -f2)" + read NFG <<< "$(grep .inactive.label.text.color ${THEMERC} | cut -d':' -f2)" + read ALINE <<< "$(grep .active.border.color ${THEMERC} | cut -d':' -f2)" + read NLINE <<< "$(grep inactive.border.color ${THEMERC} | cut -d':' -f2)" + read PHEIGHT <<< "$(grep ^padding.height: ${THEMERC} | cut -d':' -f2)" + read PWIDTH <<< "$(grep ^padding.width: ${THEMERC} | cut -d':' -f2)" + read TXTJUST <<< "$(grep text.justify ${THEMERC} | cut -d':' -f2)" + read HANDLE <<< "$(grep handle.width ${THEMERC} | cut -d':' -f2)" + read BORD <<< "$(grep border.width ${THEMERC} | cut -d':' -f2)" + read WINRAISED REST <<< "$(grep .title.bg: ${THEMERC} | cut -d':' -f2)" + read AHBG <<< "$(grep .active.handle.bg.color: ${THEMERC} | cut -d':' -f2)" + if [ "$ABG" == "$AHBG" ];then + AHANDLE="yes" + else + AHANDLE="no" + fi + +} +getvaluesrc() { +#from RC.xml + nspace="http://openbox.org/3.4/rc" + cfg="$HOME/.config/openbox/rc.xml" + + FSIZE=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' "$cfg") + FNAME=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:name' "$cfg") + NDSLIMC=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:titleLayout' "$cfg") + WEIGHT=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' "$cfg") + SLANT=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' "$cfg") +} + if [[ -f "$THEMERC" ]] && [[ "$OBTHEME" = "MBcolor"* ]]; then if [ ! -f "${THEMERC}.bak" ]; then @@ -185,40 +226,10 @@ if [[ -f "$THEMERC" ]] && [[ "$OBTHEME" = "MBcolor"* ]]; then grep ^[^#] "$THEMERC" | grep -qiF -- .text.font: || echo "window.*.text.font: shadow=n:shadowtint=70:shadowoffset=1" >> "$THEMERC" fi -getvalues () { - read ABG <<< "$(grep .active.title.bg.color: ${THEMERC} | cut -d':' -f2)" - read ABGTO <<< "$(grep .active.title.bg.colorTo ${THEMERC} | cut -d':' -f2)" - read NBG <<< "$(grep .inactive.title.bg.color: ${THEMERC} | cut -d':' -f2)" - read NBGTO <<< "$(grep .inactive.title.bg.colorTo ${THEMERC} | cut -d':' -f2)" - read AFG <<< "$(grep .active.label.text.color ${THEMERC} | cut -d':' -f2)" - read NFG <<< "$(grep .inactive.label.text.color ${THEMERC} | cut -d':' -f2)" - read ALINE <<< "$(grep .active.border.color ${THEMERC} | cut -d':' -f2)" - read NLINE <<< "$(grep inactive.border.color ${THEMERC} | cut -d':' -f2)" - read PHEIGHT <<< "$(grep ^padding.height: ${THEMERC} | cut -d':' -f2)" - read PWIDTH <<< "$(grep ^padding.width: ${THEMERC} | cut -d':' -f2)" - read TXTJUST <<< "$(grep text.justify ${THEMERC} | cut -d':' -f2)" - read HANDLE <<< "$(grep handle.width ${THEMERC} | cut -d':' -f2)" - read BORD <<< "$(grep border.width ${THEMERC} | cut -d':' -f2)" - read WINRAISED REST <<< "$(grep .title.bg: ${THEMERC} | cut -d':' -f2)" - read AHBG <<< "$(grep .active.handle.bg.color: ${THEMERC} | cut -d':' -f2)" - if [ "$ABG" == "$AHBG" ];then - AHANDLE="yes" - else - AHANDLE="no" - fi - - #from RC.xml - nspace="http://openbox.org/3.4/rc" - cfg="$HOME/.config/openbox/rc.xml" - - FSIZE=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' "$cfg") - FNAME=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:name' "$cfg") - NDSLIMC=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:titleLayout' "$cfg") - WEIGHT=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' "$cfg") - SLANT=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' "$cfg") - -} + + getvalues +getvaluesrc out+=("^sep($OBTHEME_LBL: $OBTHEME)") @@ -280,12 +291,12 @@ out2+=("Dots,obtctl buttons dots;$me") out2+=("^sep()") out2+=("Big 12px,obtctl buttons big-12;$me") out2+=("Big 14px,obtctl buttons big-14;$me") -out2+=("^sep(TITLE_LAYOUT)") +out2+=("^sep($BUTTONS_LAYOUT)") [[ "$NDSLIMC" == NDSLIMC ]] && out2+=(" full NDSLIMC (default),obtctl ndslimc NDSLIMC;$me") || out2+=(" full NDSLIMC (default),obtctl ndslimc NDSLIMC;$me") [[ "$NDSLIMC" == NLIMC ]] && out2+=(" mini NLIMC,obtctl ndslimc NLIMC;$me") || out2+=(" mini NLIMC,obtctl ndslimc NLIMC;$me") [[ "$NDSLIMC" == LIMC ]] && out2+=(" mini (no icon) LIMC,obtctl ndslimc LIMC;$me") || out2+=(" mini (no icon) LIMC,obtctl ndslimc LIMC;$me") [[ "$NDSLIMC" == CMIL ]] && out2+=(" crazy CMIL,obtctl ndslimc CMIL;$me") || out2+=(" crazy CMIL,obtctl ndslimc CMIL;$me") -out2+=("^sep(LEGEND)") +out2+=("^sep($LEGEND)") out2+=("^sep(N: Window icon)") out2+=("^sep(L: Window label (Title))") out2+=("^sep(I: Iconify (Minimize))") @@ -314,7 +325,7 @@ done 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(size)") +out2+=("^sep($FONTSIZE)") sizes=(8 9 10 11 12 13 14 15 16) for i in "${sizes[@]}" do @@ -416,14 +427,44 @@ out2+=("6,obtctl handlewidth 6;$me") out2+=("8,obtctl handlewidth 8;$me") out2+=("10,obtctl handlewidth 10;$me") -else +else # Theme other than MBColors, we can only edit rc.xml +getvaluesrc out+=("^sep($NOT_SUPORTED_OBTHEME)") out+=("$SWITCH_TO_MBCOLORS,obtctl theme MBcolors;$me") -#for i in $(ls $HOME/.themes);do -#if [ -f "$HOME/.themes/${i}/openbox-3/themerc" ]; then -#out+=("$i,obtctl theme $i;$me") -#fi -#done +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 +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") +out+=("^sep()") +out+=("$FONTSIZE [ $FSIZE px ],^checkout(obfsize)") +out2+=("^tag(obfsize)") +out2+=("^sep($FONTSIZE)") +sizes=(8 9 10 11 12 13 14 15 16) +for i in "${sizes[@]}" +do +[[ "$FSIZE" == "$i" ]] && out2+=(" $i px,obtctl fontsize $i;$me") || out2+=(" $i px,obtctl fontsize $i;$me") +done + +out+=("^sep($BUTTONS_LAYOUT)") +[[ "$NDSLIMC" == NDSLIMC ]] && out+=(" full NDSLIMC (default),obtctl ndslimc NDSLIMC;$me") || out+=(" full NDSLIMC (default),obtctl ndslimc NDSLIMC;$me") +[[ "$NDSLIMC" == NLIMC ]] && out+=(" mini NLIMC,obtctl ndslimc NLIMC;$me") || out+=(" mini NLIMC,obtctl ndslimc NLIMC;$me") +[[ "$NDSLIMC" == LIMC ]] && out+=(" mini (no icon) LIMC,obtctl ndslimc LIMC;$me") || out+=(" mini (no icon) LIMC,obtctl ndslimc LIMC;$me") +[[ "$NDSLIMC" == CMIL ]] && out+=(" crazy CMIL,obtctl ndslimc CMIL;$me") || out+=(" crazy CMIL,obtctl ndslimc CMIL;$me") +out+=("^sep($LEGEND)") +out+=("^sep(N: Window icon)") +out+=("^sep(L: Window label (Title))") +out+=("^sep(I: Iconify (Minimize))") +out+=("^sep(M: Maximize)") +out+=("^sep(C: Close)") +out+=("^sep(S: Shade (Roll up))") +out+=("^sep(D: Omnipresent (On all desktops))") fi ### RUN diff --git a/bin/obtctl b/bin/obtctl index 5bc590a..a173fb2 100755 --- a/bin/obtctl +++ b/bin/obtctl @@ -3,15 +3,18 @@ OBTHEME=$(awk '// {while (getline n) {if (match(n, //)) {l=n; exit}}} END {split(l, a, "[<>]"); print a[3]}' "$HOME/.config/openbox/rc.xml") #echo "$OBTHEME" -if [[ $OBTHEME = MBcolor* ]];then +THEMEDIR="$HOME/.themes/$OBTHEME/openbox-3" +THEMERC="$HOME/.themes/$OBTHEME/openbox-3/themerc" + +#if [[ $OBTHEME = MBcolor* ]];then #switch to MBcolors theme - THEMEDIR="$HOME/.themes/$OBTHEME/openbox-3" - THEMERC="$HOME/.themes/$OBTHEME/openbox-3/themerc" - else - xmlstarlet ed -L -N o="http://openbox.org/3.4/rc" -u '/o:openbox_config/o:theme/o:name' -v "MBcolors" "$HOME/.config/openbox/rc.xml" - THEMEDIR="$HOME/.themes/MBcolors/openbox-3" - THEMERC="$HOME/.themes/MBcolors/openbox-3/themerc" -fi +# THEMEDIR="$HOME/.themes/$OBTHEME/openbox-3" +# THEMERC="$HOME/.themes/$OBTHEME/openbox-3/themerc" +# else +# xmlstarlet ed -L -N o="http://openbox.org/3.4/rc" -u '/o:openbox_config/o:theme/o:name' -v "MBcolors" "$HOME/.config/openbox/rc.xml" +# THEMEDIR="$HOME/.themes/MBcolors/openbox-3" +# THEMERC="$HOME/.themes/MBcolors/openbox-3/themerc" +#fi MBCOLORSDIR="$HOME"/.themes/MBcolors/openbox-3/