#!/bin/bash # # colorizer - set of tools for Mabox (auto)theming # Copyright (C) 2022-2023 Daniel Napora # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . . $HOME/.config/mabox/mabox.conf me="colorizer-fonts -s" CONKYDIR="$HOME/.config/conky" BASECONKY="$CONKYDIR/sysinfo_mbcolor.conkyrc" # Favorited fonts list 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 case "$LANG" in pl*) _INCREASE_ALL="Powiększ wszystkie" _DECREASE_ALL="Pomniejsz wszystkie" _RESET="Resetuj do domyślnych" _ALL="Wszystko" _OPENBOX_WM="Openbox" _TITLEBAR_FONT="Czcionka tytułu" _BOLD="Pogrubienie" _ITALIC="Kursywa" _TEXTALIGN="Wyrównanie" _LEFT="Lewo" _CENTER="Środek" _RIGHT="Prowo" _MENUS="Menu" _MENU_TITLE="Nagłówek" _MENU_ITEM="Element" _MENU_TITLE_FONT="Czcionka nagłówka" _MENU_ITEM_FONT="Czcionka elementu" _FONT_CUSTOM="Wybierz czcionkę i rozmiar..." _FONT_FAMILY="rodzina" _EDIT_FAVFONTS="Edytuj ulubione czcionki" _FONT_SIZE="rozmiar" _INCREASE="Powiększ do" _DECREASE="Pomniejsz do" _CONKY="Conky" _CONKYFONT="Czcionka dla Conky" _CONKYBASEFONT="Czcionka podstawowa" _C_EFFECTS="Efekty" _SHADOW="Cień" _OUTLINE="Poświata" _PANEL="Panel tint2" _GTK="GTK" _FAVORITE_LBL="Ulubione czcionki" _USE="Użyj czcionki" _FOR="dla..." _COLORIZER_ROOT="Colorizer - menu główne" ;; *) _INCREASE_ALL="Increase all" _DECREASE_ALL="Decrease all" _RESET="Reset to defaults..." _ALL="All" _OPENBOX_WM="Openbox" _TITLEBAR_FONT="TitleBar Font" _BOLD="Bold" _ITALIC="Italic" _TEXTALIGN="Text align" _LEFT="Left" _CENTER="Center" _RIGHT="Right" _MENUS="Menus" _MENU_TITLE="Menu Title" _MENU_ITEM="Menu Item" _MENU_TITLE_FONT="Menu Title Font" _MENU_ITEM_FONT="Menu Item Font" _FONT_CUSTOM="Select custom font and size..." _FONT_FAMILY="font family" _EDIT_FAVFONTS="Edit favorite fonts list" _FONT_SIZE="font size" _INCREASE="Increase to" _DECREASE="Decrease to" _CONKY="Widgets (Conky)" _CONKYFONT="Conky Font" _CONKYBASEFONT="Base font" _C_EFFECTS="Effects" _SHADOW="Shadow" _OUTLINE="Outline" _PANEL="Panel Tint2" _GTK="GTK Font" _FAVORITE_LBL="Favorite Fonts" _USE="Use" _FOR="font for ..." _COLORIZER_ROOT="Colorizer rootmenu" ;; esac getvalues () { GTK2RC="$HOME"/.gtkrc-2.0 GTK_FONT=( $(grep "gtk-font-name" ${GTK2RC} | cut -d'"' -f2) ) GTK_FAMILY=${GTK_FONT[@]::${#GTK_FONT[@]}-1} GTK_SIZE=${GTK_FONT[-1]} nspace="http://openbox.org/3.4/rc" obcfg="$HOME/.config/openbox/rc.xml" OBFSIZE=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' "$obcfg") OBFNAME=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:name' "$obcfg") 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' "$obcfg") SLANT=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' "$obcfg") OBTHEME=$(awk '// {while (getline n) {if (match(n, //)) {l=n; exit}}} END {split(l, a, "[<>]"); print a[3]}' "$HOME/.config/openbox/rc.xml") THEMERC="$HOME/.themes/$OBTHEME/openbox-3/themerc" if [ -f "$THEMERC" ];then read TXTJUST <<< "$(grep text.justify ${THEMERC} | cut -d':' -f2)" else : fi read FONTDEF <<< "$(grep "font .*=.*,$" ${BASECONKY} | cut -d'=' -f2,3 |cut -d"'" -f2)" C_FONT=${FONTDEF%:*} C_FONTSIZE=${FONTDEF#*=} read OUTLINE <<< "$(grep draw_outline ${BASECONKY} | cut -d'=' -f2 | cut -d"," -f1)" read SHADES <<< "$(grep draw_shades ${BASECONKY} | cut -d'=' -f2 | cut -d"," -f1)" SHADOWS="no" [[ "$OUTLINE" == "true" ]] && SHADOWS="outline" [[ "$SHADES" == "true" ]] && SHADOWS="shadow" } getvalues out+=("󰧴 $_INCREASE_ALL,fontctl inc_all;$me") out+=("󰧳 $_DECREASE_ALL,fontctl dec_all;$me") out+=("^sep()") out+=("󰑓 $_RESET,^checkout(reset)") out2+=("^tag(reset)") out2+=("^sep($_RESET)") out2+=("$_ALL,fontctl resetall;$me") out2+=("^sep()") out2+=("$_TITLEBAR_FONT,fontctl resetob;$me") out2+=("$_MENUS,fontctl resetmenus;$me") out2+=("$_CONKY,fontctl resetconky;$me") out2+=("$_GTK,fontctl resetgtk;$me") out+=("^sep($_OPENBOX_WM)") out+=("$_TITLEBAR_FONT [ $OBFNAME $OBFSIZE ],^checkout(obtitletext)") out+=("^sep($_MENUS)") out+=("$_MENU_TITLE [ $menu_sep_font_family $menu_sep_font_size ],^checkout(mtitlefont)") out+=("$_MENU_ITEM [ $menu_font_family $menu_font_size ],^checkout(mitemfont)") out+=("^sep($_GTK)") out+=("$_GTK [ ${GTK_FAMILY} ${GTK_SIZE} ],^checkout(gtkfont)") out+=("^sep($_CONKY)") out+=("$_CONKYBASEFONT [ $C_FONT $C_FONTSIZE ],^checkout(conkyfont)") #out+=("^sep($_PANEL)") #out+=("(not implemented yet)") # FAV FONTS in rootmenu if [ "${#favfonts[@]}" -gt 0 ];then out+=("^sep($_FAVORITE_LBL)") i=0 for fon in "${favfonts[@]}";do out+=(" ${fon},^checkout(favfont$i),$me") out2+=("^tag(favfont$i)") out2+=("^sep($_USE)") out2+=("^sep(${fon})") out2+=("^sep($_FOR)") out2+=("$_TITLEBAR_FONT,obtctl fontfamily \"${fon}\";$me") out2+=("$_MENU_TITLE,mb-setvar \"menu_sep_font_family='${fon}'\";$me") out2+=("$_MENU_ITEM,mb-setvar \"menu_font_family='${fon}'\";$me") out2+=("$_GTK,fontctl gtk_fontfamily \"${fon}\";$me") out2+=("$_CONKY,conkyctl basefont_family_all \"${fon}\";$me") i=$((i+1)) done out+=("^sep()") out+=(" $_EDIT_FAVFONTS ,geany ~/.config/mabox/fonts.list") fi #SUBMENUS # OpenBox Title Font out2+=("^tag(obtitletext)") out2+=("^sep($_TITLEBAR_FONT)") out2+=("^sep($OBFNAME $OBFSIZE)") out2+=("󰛖 $_FONT_CUSTOM,mb-setfont obtitle;$me") out2+=("^sep($_FONT_SIZE)") out2+=("󰧴 $_INCREASE $((OBFSIZE+1)) px,fontctl ob_fontsize inc;$me") out2+=("󰧳 $_DECREASE $((OBFSIZE-1)) px,fontctl ob_fontsize dec;$me") out2+=("^sep()") sizes=(16 15 14 13 12 11 10 9 8) for i in "${sizes[@]}" do [[ "$OBFSIZE" == "$i" ]] && out2+=(" $i px,obtctl fontsize $i;$me") || out2+=(" $i px,fontctl ob_fontsize $i;$me") done out2+=("^sep($_FONT_FAMILY)") if [ "${#favfonts[@]}" -gt 0 ];then for fon in "${favfonts[@]}";do [[ "${OBFNAME}" == "$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") #SHADOW out2+=("^sep($_TEXTALIGN)") [[ "$TXTJUST" = left ]] && out2+=("綠  $_LEFT,obtctl textjustify left;$me")||out2+=("祿  $_LEFT,obtctl textjustify left;$me") [[ "$TXTJUST" = center ]] && out2+=("綠  $_CENTER,obtctl textjustify center;$me")||out2+=("祿  $_CENTER,obtctl textjustify center;$me") [[ "$TXTJUST" = right ]] && out2+=("綠  $_RIGHT,obtctl textjustify right;$me")||out2+=("祿  $_RIGHT,obtctl textjustify right;$me") # Menu Title Font out2+=("^tag(mtitlefont)") out2+=("^sep($_MENU_TITLE_FONT)") out2+=("^sep($menu_sep_font_family $menu_sep_font_size)") out2+=("󰛖 $_FONT_CUSTOM,mb-setfont menu_sep;$me") out2+=("^sep($_FONT_SIZE)") out2+=("󰧴 $_INCREASE $((menu_sep_font_size+1)) px,mb-setvar menu_sep_font_size=$((menu_sep_font_size+1));$me") out2+=("󰧳 $_DECREASE $((menu_sep_font_size-1)) px,mb-setvar menu_sep_font_size=$((menu_sep_font_size-1));$me") out2+=("^sep()") sizes=(14 13 12 11 10 9 8) for i in "${sizes[@]}" do [[ "$menu_sep_font_size" == "$i" ]] && out2+=(" $i px,$me") || out2+=(" $i px,mb-setvar menu_sep_font_size=$i;$me") done if [ "${#favfonts[@]}" -gt 0 ];then out2+=("^sep($_FONT_FAMILY)") for fon in "${favfonts[@]}";do [[ "$menu_sep_font_family" == "$fon" ]] && out2+=(" ${fon},$me") || out2+=(" ${fon},mb-setvar \"menu_sep_font_family='${fon}'\";$me") done fi out2+=("^sep()") out2+=(" $_EDIT_FAVFONTS ,geany ~/.config/mabox/fonts.list") # Item font submenu out2+=("^tag(mitemfont)") out2+=("^sep($_MENU_ITEM_FONT)") out2+=("^sep($menu_font_family $menu_font_size)") out2+=("󰛖 $_FONT_CUSTOM,mb-setfont menu_item;$me") out2+=("^sep($_FONT_SIZE)") out2+=("󰧴 $_INCREASE $((menu_font_size+1)) px,mb-setvar menu_font_size=$((menu_font_size+1));$me") out2+=("󰧳 $_DECREASE $((menu_font_size-1)) px,mb-setvar menu_font_size=$((menu_font_size-1));$me") out2+=("^sep()") sizes=(14 13 12 11 10 9 8) for i in "${sizes[@]}" do [[ "$menu_font_size" == "$i" ]] && out2+=(" $i px,$me") || out2+=(" $i px,mb-setvar menu_font_size=$i;$me") done if [ "${#favfonts[@]}" -gt 0 ];then out2+=("^sep($_FONT_FAMILY)") for fon in "${favfonts[@]}";do [[ "$menu_font_family" == "$fon" ]] && out2+=(" ${fon},$me") || out2+=(" ${fon},mb-setvar \"menu_font_family='${fon}'\";$me") done fi out2+=("^sep()") out2+=(" $_EDIT_FAVFONTS,geany ~/.config/mabox/fonts.list") # Conky out2+=("^tag(conkyfont)") out2+=("^sep($_CONKYFONT)") out2+=("^sep($C_FONT $C_FONTSIZE)") out2+=("󰛖 $_FONT_CUSTOM,mb-setfont conky_all;$me") out2+=("^sep($_FONT_SIZE)") out2+=("󰧴 $_INCREASE $((C_FONTSIZE+1)) px,conkyctl basefont_inc_all;$me") out2+=("󰧳 $_DECREASE $((C_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 [[ "$C_FONTSIZE" == "$i" ]] && out2+=(" $i px,conkyctl basefont_size_all $i;$me") || out2+=(" $i px,conkyctl basefont_size_all $i;$me") done if [ "${#favfonts[@]}" -gt 0 ];then out2+=("^sep($_FONT_FAMILY)") for fon in "${favfonts[@]}";do [[ "$C_FONT" == "$fon" ]] && out2+=(" ${fon},$me") || out2+=(" ${fon},conkyctl basefont_family_all \"${fon}\";$me") done fi out2+=("^sep()") out2+=(" $_EDIT_FAVFONTS,geany ~/.config/mabox/fonts.list") out2+=("^sep($_C_EFFCTS)") [[ "$SHADOWS" == "shadow" ]] && out2+=("󰄲 $_SHADOW,conkyctl shades_all no;$me") || out2+=("󰄱 $_SHADOW,conkyctl shades_all shadow;$me") [[ "$SHADOWS" == "outline" ]] && out2+=("󰄲 $_OUTLINE,conkyctl shades_all no;$me") || out2+=("󰄱 $_OUTLINE,conkyctl shades_all outline;$me") # GTK 2/3 font out2+=("^tag(gtkfont)") out2+=("^sep($_GTK)") out2+=("^sep($menu_font_family $menu_font_size)") out2+=("󰛖 $_FONT_CUSTOM,mb-setfont gtk;$me") out2+=("^sep($_FONT_SIZE)") out2+=("󰧴 $_INCREASE $((GTK_SIZE+1)) px,fontctl gtk_fontsize inc;$me") out2+=("󰧳 $_DECREASE $((GTK_SIZE-1)) px,fontctl gtk_fontsize dec;$me") out2+=("^sep()") sizes=(14 13 12 11 10 9 8) for i in "${sizes[@]}" do [[ "$GTK_SIZE" == "$i" ]] && out2+=(" $i px,$me") || out2+=(" $i px,fontctl gtk_fontsize $i;$me") done if [ "${#favfonts[@]}" -gt 0 ];then out2+=("^sep($_FONT_FAMILY)") for fon in "${favfonts[@]}";do [[ "$GTK_FAMILY" == "$fon" ]] && out2+=(" ${fon},$me") || out2+=(" ${fon},fontctl gtk_fontfamily \"${fon}\";$me") done fi out2+=("^sep()") out2+=(" $_EDIT_FAVFONTS,geany ~/.config/mabox/fonts.list") ### RUN if [[ "$1" == "-s" ]]; then . /usr/share/mb-jgtools/pipemenu-standalone.cfg CNF_DIR="$HOME/.config/colorizer" CNF_FILE="$CNF_DIR/colorizer.conf" source "$CNF_FILE" out+=("^sep()") out+=(" ${arrow_string_left} $_COLORIZER_ROOT,colorizer -s") if [[ "$colorizer_size" == "full" ]];then eval $(xdotool getdisplaygeometry --shell) MENU_HEIGHT_MIN="$HEIGHT" MENU_HEIGHT_MAX=$MENU_HEIGHT_MIN jgtools_radius=0 menu_margin_x="0" else MENU_VALIGN="center" menu_margin_x=${submenu_spacing:-0} fi MENU_HALIGN="left" jgmenu_icon_size=0 [ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius [ -z $jgmenu_use_borders ] && menu_border=0 JGWIDTH=$((jgtools_padding + 270 + jgtools_padding)) MENU_PADDING_TOP=$((jgtools_padding + 150)) #WALLPAPER read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) THUMBDIR="$HOME/.cache/colorizer/thumbs" mkdir -p ${THUMBDIR} NAME=${WALLPATH////_} if [[ "${NAME}" =~ ^_home_.* ]]; then n=${#HOME} ((n++)) NAME=${NAME:${n}} fi THUMB="${THUMBDIR}/${NAME}.png" if [[ ! -f "$THUMB" ]] then convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} fi mkconfigfile [[ "$GR" == "1" ]] && clr=${GR_FROM} || clr=${FG} cat < ${MENU_ITEMS} @icon,,$((jgtools_padding)),$((jgtools_padding)),270,150,4,left,top,,,${THUMB} #@icon,,$((jgtools_padding + 4)),$((jgtools_padding + 4)),270,150,4,left,top,,,/usr/share/mabox-colorizer/img/colorizer-conky.png @rect,,$((jgtools_padding)),$((jgtools_padding + 116)),270,28,0,left,top,#222222 20,#222222 70, @text,,$((jgtools_padding + 10)),$((jgtools_padding + 106)),100,28,0,left,top,#FFFFFF ,${WINCLR}, @text,,$((jgtools_padding + 128)),$((jgtools_padding + 116)),150,28,0,left,top,#FFFFFF ,${WINCLR},Mabox Fonts config $(printf '%s\n' "${out[@]}") $(printf '%s\n' "${out2[@]}") EOF jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null exit 0 fi printf '%s\n' "${out[@]}" printf '%s\n' "${out2[@]}"