mabox-colorizer/bin/colorizer-ob

259 lines
11 KiB
Plaintext
Raw Normal View History

2022-05-15 03:25:01 +02:00
#!/bin/bash
2022-05-15 17:42:35 +02:00
MBCOLORSDIR="$HOME"/.themes/MBcolors/openbox-3/
2022-05-15 03:25:01 +02:00
2022-05-15 17:42:35 +02:00
if [ ! -d "$MBCOLORSDIR" ]; then
2022-05-15 03:25:01 +02:00
mkdir -p ${MBCOLORSDIR}
rsync -a /usr/share/mabox-colorizer/themes/MBcolors/openbox-3/* ${MBCOLORSDIR}/
fi
OBTHEME=$(awk '/<theme>/ {while (getline n) {if (match(n, /<name>/))
{l=n; exit}}} END {split(l, a, "[<>]"); print a[3]}' "$HOME/.config/openbox/rc.xml")
THEMERC="$HOME/.themes/$OBTHEME/openbox-3/themerc"
me="colorizer-ob -s"
if [ -f "$THEMERC" ]; then
if [ ! -f "${THEMERC}.bak" ]; then
cp ${THEMERC} ${THEMERC}.bak
#check if lines, and add missing
# colorTo
# handle
# grip
# text.justify
# window.active.label.text.font:shadow=n:shadowtint=70:shadowoffset=1
#grep -qF -- "$LINE" "$FILE" || echo "$LINE" >> "$FILE"
grep ^[^#] "$THEMERC" | grep -qiF -- .active.title.bg.colorTo || echo "window.active.title.bg.colorTo: #222222" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .inactive.title.bg.colorTo || echo "window.inactive.title.bg.colorTo: #222222" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- handle.width: || echo "window.handle.width: 0" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .handle.bg: || echo "window.*.handle.bg: parentrelative" >> "$THEMERC"
################################################################################################################################## Kolory poniżej obliczyć
grep ^[^#] "$THEMERC" | grep -qiF -- .active.handle.bg.color: || echo "window.active.handle.bg.color: #222222" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .active.handle.bg.colorTo: || echo "window.active.handle.bg.colorTo: #222222" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .inactive.handle.bg.color: || echo "window.inactive.handle.bg.color: #222222" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .inactive.handle.bg.colorTo: || echo "window.inactive.handle.bg.colorTo: #222222" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .grip.bg: || echo "window.*.grip.bg: parentrelative" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .active.grip.bg.color: || echo "window.active.grip.bg.color: #222222" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .active.grip.bg.colorTo: || echo "window.active.grip.bg.colorTo: #222222" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .inactive.grip.bg.color: || echo "window.inactive.grip.bg.color: #222222" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .inactive.grip.bg.colorTo: || echo "window.inactive.grip.bg.colorTo: #222222" >> "$THEMERC"
grep ^[^#] "$THEMERC" | grep -qiF -- .text.justify: || echo "window.*.text.justify: center" >> "$THEMERC"
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
}
getvalues
out+=("^sep(Openbox theme: <i>$OBTHEME</i>)")
out+=("^sep(TITLEBAR)")
out+=("<tt><span bgcolor='$ABG'> </span></tt> ACTIVE_BG,^pipe(mbclr '$ABG' obtctl clractivebg ACTIVE_BG '$me')")
out+=("<tt><span bgcolor='$NBG'> </span></tt> INACTIVE_BG,^pipe(mbclr '$NBG' obtctl clrnormalbg INACTIVE_BG '$me')")
out+=("<tt><span bgcolor='$ABG' fgcolor='$AFG'> <b>AbCd</b> </span></tt> TITLEBAR TEXT,^checkout(titletext)")
2022-05-15 03:25:01 +02:00
2022-06-03 19:43:56 +02:00
out+=("PADDING [ <b>$PHEIGHT $PWIDTH</b> ],^checkout(padding)")
out+=("Raised or flat? [ <b>$WINRAISED</b> ],^checkout(raised)")
out+=("^sep(Gradient)")
out+=("Gradient type [ <b>${REST##* }</b> ],^checkout(gradient)")
[[ ! -z "$ABGTO" ]] && out+=("<tt><span bgcolor='$ABG'> </span><span bgcolor='$ABGTO'> </span></tt> ACTIVE_BG_TO,^pipe(mbclr '$ABGTO' obtctl clractivebgto ACTIVE_BG_TO '$me')")
[[ ! -z "$ABGTO" ]] && out+=("<tt><span bgcolor='$NBG'> </span><span bgcolor='$NBGTO'> </span></tt> INACTIVE_BG_TO,^pipe(mbclr '$NBGTO' obtctl clrnormalbgto INACTIVE_BG_TO '$me')")
2022-05-15 03:25:01 +02:00
out+=("^sep(BORDER)")
out+=("<tt><span bgcolor='$ALINE'> </span></tt> ACTIVE_BORDER,^pipe(mbclr '$ALINE' obtctl activeborderColor ACTIVE_BORDER_COLOR '$me')")
out+=("<tt><span bgcolor='$NLINE'> </span></tt> INACTIVE_BORDER,^pipe(mbclr '$NLINE' obtctl inactiveborderColor INACTIVE_BORDER_COLOR '$me')")
2022-06-03 19:43:56 +02:00
out+=("BORDER [ <b>$BORD</b> ],^checkout(border)")
out+=("HANDLEWIDTH [ <b>$HANDLE</b> ],^checkout(handlewidth)")
out+=("ACTIVEHANDLE? [ <b>$AHANDLE</b> ],^checkout(handle)")
2022-05-15 03:25:01 +02:00
if [ -f "${THEMERC}.bak" ]; then
out+=("^sep()")
2022-05-15 03:25:01 +02:00
out+=("RESET TO DEFAULTS,obtctl reset;$me")
fi
#out+=("Edit...,xdg-open ${THEMERC}")
2022-05-15 18:50:21 +02:00
#out2+=("^tag(themes)")
#out2+=("^sep(themes)")
#for i in $(ls $HOME/.themes);do
# if [ -f "$HOME/.themes/${i}/openbox-3/themerc" ]; then
# out2+=("$i,obtctl theme $i;$me")
# fi
#done
2022-05-15 03:25:01 +02:00
#TEXT
out2+=("^tag(titletext)")
out2+=("^sep(TITLE_BAR TEXT)")
2022-05-15 03:25:01 +02:00
out2+=("FONT...,mb-setfont obtitle;$me")
out2+=("TEXTALIGN [ $TXTJUST ],^checkout(talign)")
out2+=("SHADOW,^checkout(shadow)")
out2+=("^sep()")
2022-05-19 14:50:08 +02:00
out2+=("<tt><span bgcolor='$AFG'> </span></tt> ACTIVE_FG,^pipe(mbclr '$AFG' obtctl activetextcolor ACTIVE_COLOR '$me')")
out2+=("<tt><span bgcolor='$NFG'> </span></tt> INACTIVE_FG,^pipe(mbclr '$NFG' obtctl inactivetextcolor INACTIVE_COLOR '$me')")
2022-05-15 03:25:01 +02:00
#TEXTALIGN
out2+=("^tag(talign)")
out2+=("^sep(TEXTALIGN)")
out2+=("center,obtctl textjustify center;$me")
out2+=("left,obtctl textjustify left;$me")
out2+=("right,obtctl textjustify right;$me")
out2+=("^tag(shadow)")
out2+=("^sep(SHADOW)")
out2+=("no shadow,obtctl shadow 0;$me")
out2+=("^sep()")
out2+=("Dark,obtctl shadow 1;$me")
out2+=("Light,obtctl shadow 2;$me")
#PADDING
out2+=("^tag(padding)")
out2+=("^sep(VERTICAL)")
out2+=("0,obtctl paddingHeight 0;$me")
out2+=("^sep()")
out2+=("1,obtctl paddingHeight 1;$me")
out2+=("2,obtctl paddingHeight 2;$me")
out2+=("3,obtctl paddingHeight 3;$me")
out2+=("4,obtctl paddingHeight 4;$me")
out2+=("5,obtctl paddingHeight 5;$me")
out2+=("6,obtctl paddingHeight 6;$me")
out2+=("7,obtctl paddingHeight 7;$me")
out2+=("8,obtctl paddingHeight 8;$me")
out2+=("10,obtctl paddingHeight 10;$me")
out2+=("^sep(HORIZONTAL)")
out2+=("0,obtctl paddingWidth 0;$me")
out2+=("^sep()")
out2+=("1,obtctl paddingWidth 1;$me")
out2+=("2,obtctl paddingWidth 2;$me")
out2+=("3,obtctl paddingWidth 3;$me")
out2+=("4,obtctl paddingWidth 4;$me")
out2+=("5,obtctl paddingWidth 5;$me")
#BORDER
out2+=("^tag(border)")
out2+=("^sep(border)")
out2+=("0,obtctl borderWidth 0;$me")
out2+=("^sep()")
out2+=("1,obtctl borderWidth 1;$me")
out2+=("2,obtctl borderWidth 2;$me")
out2+=("3,obtctl borderWidth 3;$me")
out2+=("4,obtctl borderWidth 4;$me")
out2+=("5,obtctl borderWidth 5;$me")
#RAISED
out2+=("^tag(raised)")
2022-06-03 19:43:56 +02:00
out2+=("^sep(Raised or flat?)")
2022-05-15 03:25:01 +02:00
out2+=("0 (flat),obtctl raised 0;$me")
out2+=("1 (raised),obtctl raised 1;$me")
#GRADIENT
out2+=("^tag(gradient)")
out2+=("^sep(GRADIENT)")
out2+=("Solid color (no gradient),obtctl gradient solid;$me")
2022-05-15 03:25:01 +02:00
out2+=("^sep()")
out2+=("Vertical,obtctl gradient vertical;$me")
out2+=("Horizontal,obtctl gradient horizontal;$me")
out2+=("MirrorHorizontal,obtctl gradient mirrorhorizontal;$me")
out2+=("SplitVertical,obtctl gradient splitvertical;$me")
out2+=("Diagonal,obtctl gradient diagonal;$me")
out2+=("CrossDiagonal,obtctl gradient crossdiagonal;$me")
out2+=("Pyramid,obtctl gradient pyramid;$me")
2022-06-03 19:43:56 +02:00
2022-05-15 03:25:01 +02:00
#HANDLE
out2+=("^tag(handle)")
out2+=("^sep(ACTIVEHANDLE)")
out2+=("NO,obtctl activehandle no;$me")
out2+=("YES,obtctl activehandle yes;$me")
out2+=("GRIPONLY,obtctl activehandle grip;$me")
#HANDLE
out2+=("^tag(handlewidth)")
out2+=("^sep(HANDLEWIDTH)")
out2+=("0,obtctl handlewidth 0;$me")
out2+=("^sep()")
out2+=("2,obtctl handlewidth 2;$me")
out2+=("3,obtctl handlewidth 3;$me")
out2+=("4,obtctl handlewidth 4;$me")
out2+=("6,obtctl handlewidth 6;$me")
out2+=("8,obtctl handlewidth 8;$me")
out2+=("10,obtctl handlewidth 10;$me")
else
2022-05-15 18:50:21 +02:00
out+=("^sep(NOT SUPORTED OB theme)")
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
2022-05-15 03:25:01 +02:00
fi
### RUN
if [[ "$1" == "-s" ]]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
out+=("^sep()")
out+=(" ⮜ Back to Colorizer,colorizer -s")
if [[ $panels_heightpos == "top" ]]; then
MENU_VALIGN="top"
MENU_MARGIN_Y=${panels_topmargin:-0}
elif [[ $panels_heightpos == "bottom" ]]; then
MENU_VALIGN="bottom"
MENU_MARGIN_Y=${panels_topmargin:-0}
else
MENU_VALIGN="center"
fi
MENU_PADDING_TOP=${jgtools_padding:-0}
MENU_HALIGN="left"
jgmenu_icon_size=0
JGWIDTH=40
menu_margin_x=${submenu_spacing:-0}
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
JGWIDTH=$((jgtools_padding + 278 + jgtools_padding))
MENU_PADDING_TOP=$((jgtools_padding + 158))
# WALLPAPER IMAGE
read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2)
WALLPAPER=${WALLPATH##*/}
THUMBDIR="$HOME/.config/mabox/wallthumbs"
mkdir -p ${THUMBDIR}
THUMB="${THUMBDIR}/${WALLPAPER}.png"
if [[ ! -f "$THUMB" ]]
then
convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB}
fi
#TEMP POSITION:
MENU_VALIGN="top"
2022-05-15 14:16:06 +02:00
MENU_MARGIN_Y="60"
2022-05-15 03:25:01 +02:00
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
@icon,,$((jgtools_padding + 4)),$((jgtools_padding + 4)),270,150,4,left,top,,,${THUMB}
2022-05-15 14:16:06 +02:00
@icon,,$((jgtools_padding + 4)),$((jgtools_padding + 4)),270,150,4,left,top,,,/usr/share/mabox-colorizer/img/colorizer-ob.png
2022-05-15 03:25:01 +02:00
$(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[@]}"