mabox-colorizer/bin/obtctl

940 lines
35 KiB
Plaintext
Raw Normal View History

2022-05-15 03:25:01 +02:00
#!/bin/bash
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")
#echo "$OBTHEME"
THEMEDIR="$HOME/.themes/$OBTHEME/openbox-3"
THEMERC="$HOME/.themes/$OBTHEME/openbox-3/themerc"
#if [[ $OBTHEME = MBcolor* ]];then
2023-07-25 14:23:08 +02:00
#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
2023-07-25 14:23:08 +02:00
2022-05-15 03:25:01 +02:00
2022-12-17 12:12:52 +01:00
MBCOLORSDIR="$HOME"/.themes/MBcolors/openbox-3/
if [ ! -d "$MBCOLORSDIR" ]; then
mkdir -p ${MBCOLORSDIR}
rsync -a /usr/share/mabox-colorizer/themes/MBcolors/openbox-3/* ${MBCOLORSDIR}/
fi
2022-05-15 03:25:01 +02:00
if [ ! -f "${THEMERC}.bak" ]; then
cp ${THEMERC} ${THEMERC}.bak
fi
theme () {
xmlstarlet ed -L -N o="http://openbox.org/3.4/rc" -u '/o:openbox_config/o:theme/o:name' -v "$1" "$HOME/.config/openbox/rc.xml"
}
reset () {
rm ${THEMERC}
mv ${THEMERC}.bak ${THEMERC}
2022-12-23 11:10:27 +01:00
}
resetonlycolors () {
theme MBcolors
clractivebg "#579c8e"
clractivebgto "#41756a"
2022-05-15 03:25:01 +02:00
}
2022-12-17 12:12:52 +01:00
resetMBcolors() {
theme MBcolors
rsync -a /usr/share/mabox-colorizer/themes/MBcolors/openbox-3/* ${MBCOLORSDIR}/
2022-12-19 22:22:23 +01:00
#set font
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:name' -v "Ubuntu" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' -v "9" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' -v "Bold" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' -v "Normal" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:name' -v "Ubuntu" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:size' -v "9" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:weight' -v "Bold" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:slant' -v "Normal" "$cfg"
2024-09-04 12:58:53 +02:00
rm ${THEMERC}.bak
2022-12-17 12:12:52 +01:00
}
2022-05-15 03:25:01 +02:00
borderWidth () {
2022-12-17 12:12:52 +01:00
case "$1" in
increase)
read BWIDTH <<< "$(grep border.width: ${THEMERC} | cut -d':' -f2)"
BWIDTH=$((BWIDTH+1))
sd "^border.width:.*$" "border.width: ${BWIDTH}" ${THEMERC}
;;
decrease)
read BWIDTH <<< "$(grep border.width: ${THEMERC} | cut -d':' -f2)"
if [ "$BWIDTH" -gt "0" ];then
BWIDTH=$((BWIDTH-1))
sd "^border.width:.*$" "border.width: ${BWIDTH}" ${THEMERC}
fi
;;
2023-09-23 13:57:32 +02:00
*)
2022-12-17 12:12:52 +01:00
sd "^border.width:.*$" "border.width: $1" ${THEMERC}
;;
esac
2022-05-15 03:25:01 +02:00
}
activeborderColor () {
sd "\.active.border.color:.*$" ".active.border.color: $1" ${THEMERC}
2024-09-04 12:58:53 +02:00
read BORD <<< "$(grep border.width ${THEMERC} | cut -d':' -f2)"
[[ "$BORD" == 0 ]] && borderWidth 1
2022-05-15 03:25:01 +02:00
}
inactiveborderColor () {
sd "\.inactive.border.color:.*$" ".inactive.border.color: $1" ${THEMERC}
2024-09-04 12:58:53 +02:00
read BORD <<< "$(grep border.width ${THEMERC} | cut -d':' -f2)"
[[ "$BORD" == 0 ]] && borderWidth 1
2022-05-15 03:25:01 +02:00
}
paddingHeight () {
2022-12-17 12:12:52 +01:00
case "$1" in
increase)
read PHEIGHT <<< "$(grep ^padding.height: ${THEMERC} | cut -d':' -f2)"
PHEIGHT=$((PHEIGHT+1))
sd "^padding.height:.*$" "padding.height: ${PHEIGHT}" ${THEMERC}
sd "^padding.width:.*$" "padding.width: ${PHEIGHT}" ${THEMERC}
;;
decrease)
read PHEIGHT <<< "$(grep ^padding.height: ${THEMERC} | cut -d':' -f2)"
if [ "$PHEIGHT" -gt "0" ];then
PHEIGHT=$((PHEIGHT-1))
sd "^padding.height:.*$" "padding.height: ${PHEIGHT}" ${THEMERC}
sd "^padding.width:.*$" "padding.width: ${PHEIGHT}" ${THEMERC}
fi
;;
2024-02-22 14:24:51 +01:00
0|1|2|3|4|5|6|8|10|12|16|20)
2022-12-17 12:12:52 +01:00
sd "^padding.height:.*$" "padding.height: $1" ${THEMERC}
sd "^padding.width:.*$" "padding.width: $1" ${THEMERC}
;;
esac
2022-05-15 03:25:01 +02:00
}
paddingWidth () {
sd "^padding.width:.*$" "padding.width: $1" ${THEMERC}
}
textjustify () {
sd "\.text.justify:.*$" ".text.justify: $1" ${THEMERC}
}
shadow () {
case "$1" in
2022-12-19 22:22:23 +01:00
0|no)
2022-05-15 03:25:01 +02:00
sd "\.active.label.text.font:.*$" ".active.label.text.font: shadow=n:shadowtint=70:shadowoffset=1" ${THEMERC}
sd "\.inactive.label.text.font:.*$" ".inactive.label.text.font: shadow=n:shadowtint=20:shadowoffset=1" ${THEMERC}
;;
2022-12-19 22:22:23 +01:00
1|dark)
2022-05-15 03:25:01 +02:00
sd "\.active.label.text.font:.*$" ".active.label.text.font: shadow=y:shadowtint=70:shadowoffset=1" ${THEMERC}
2022-12-19 22:22:23 +01:00
#sd "\.inactive.label.text.font:.*$" ".inactive.label.text.font: shadow=y:shadowtint=20:shadowoffset=1" ${THEMERC}
2022-05-15 03:25:01 +02:00
;;
2022-12-19 22:22:23 +01:00
2|light)
sd "\.active.label.text.font:.*$" ".active.label.text.font: shadow=y:shadowtint=-40:shadowoffset=1" ${THEMERC}
#sd "\.inactive.label.text.font:.*$" ".inactive.label.text.font: shadow=y:shadowtint=-20:shadowoffset=1" ${THEMERC}
2022-05-15 03:25:01 +02:00
;;
2022-09-19 20:59:26 +02:00
esac
2022-05-15 03:25:01 +02:00
}
handlewidth () {
sd "\.handle.width:.*$" ".handle.width: $1" ${THEMERC}
}
raised () {
2022-12-08 17:48:55 +01:00
#flat 0 or raised 1 or sunken 2
2022-05-15 03:25:01 +02:00
read WINRAISED REST <<< "$(grep .title.bg: ${THEMERC} | cut -d':' -f2)"
case "$1" in
2022-12-19 22:22:23 +01:00
0|flat)
2022-05-15 03:25:01 +02:00
sd "\.title.bg:.*$" ".title.bg: flat ${REST}" ${THEMERC}
sd "\.handle.bg:.*$" ".handle.bg: flat ${REST}" ${THEMERC}
sd "\.grip.bg:.*$" ".grip.bg: flat ${REST}" ${THEMERC}
2022-09-19 20:59:26 +02:00
;;
2022-12-19 22:22:23 +01:00
1|raised)
2022-05-15 03:25:01 +02:00
sd "\.title.bg:.*$" ".title.bg: raised ${REST}" ${THEMERC}
sd "\.handle.bg:.*$" ".handle.bg: raised ${REST}" ${THEMERC}
sd "\.grip.bg:.*$" ".grip.bg: raised ${REST}" ${THEMERC}
2022-09-19 20:59:26 +02:00
;;
2022-12-19 22:22:23 +01:00
2|sunken)
2022-09-19 20:59:26 +02:00
sd "\.title.bg:.*$" ".title.bg: sunken ${REST}" ${THEMERC}
sd "\.handle.bg:.*$" ".handle.bg: sunken ${REST}" ${THEMERC}
sd "\.grip.bg:.*$" ".grip.bg: sunken ${REST}" ${THEMERC}
;;
2022-05-15 03:25:01 +02:00
esac
}
2022-12-19 22:22:23 +01:00
gradient_type () {
2022-05-15 03:25:01 +02:00
#solid or gradient gradient-type
read WINRAISED REST <<< "$(grep .title.bg: ${THEMERC} | cut -d':' -f2)"
case "$1" in
solid)
sd "\.title.bg:.*$" ".title.bg: ${WINRAISED} solid" ${THEMERC}
sd "\.handle.bg:.*$" ".handle.bg: ${WINRAISED} solid" ${THEMERC}
sd "\.grip.bg:.*$" ".grip.bg: ${WINRAISED} solid" ${THEMERC}
2022-09-19 20:59:26 +02:00
;;
2022-05-15 03:25:01 +02:00
*)
sd "\.title.bg:.*$" ".title.bg: ${WINRAISED} gradient ${1}" ${THEMERC}
sd "\.handle.bg:.*$" ".handle.bg: ${WINRAISED} gradient ${1}" ${THEMERC}
sd "\.grip.bg:.*$" ".grip.bg: ${WINRAISED} gradient ${1}" ${THEMERC}
2022-09-19 20:59:26 +02:00
;;
2022-05-15 03:25:01 +02:00
esac
}
2022-12-19 22:22:23 +01:00
random_gradient () {
GRADIENT_FILE="$HOME"/.config/colorizer/gradients_all.inc
if [ ! -f $GRADIENT_FILE ]; then
cp -a /usr/share/mabox-colorizer/gradients_all.inc $GRADIENT_FILE
fi
read CLR CLRTO REST <<< "$(shuf -n 1 $GRADIENT_FILE)"
activegradient "$CLR" "$CLRTO"
}
2022-09-19 20:59:26 +02:00
activegradient () {
2023-09-23 13:57:32 +02:00
# ACTIVE
# ACTIVE GRIP and HANDLE
colorTo=$(pastel darken 0.1 "${1}"|pastel format hex)
#activehandle?
###read ABG <<< "$(grep .active.title.bg.color: ${THEMERC} | cut -d':' -f2)"
###read AHBG <<< "$(grep .active.handle.bg.color: ${THEMERC} | cut -d':' -f2)"
###if [ "$ABG" == "$AHBG" ];then
###fi
sd "\.active.grip.bg.color:.*$" ".active.grip.bg.color: ${1}" ${THEMERC}
sd "\.active.grip.bg.colorTo:.*$" ".active.grip.bg.colorTo: ${colorTo}" ${THEMERC}
sd "^window.active.title.bg.color:.*$" "window.active.title.bg.color: ${1}" ${THEMERC}
sd "\.active.border.color:.*$" ".active.border.color: ${1}" ${THEMERC}
sd "^window.active.title.bg.colorTo:.*$" "window.active.title.bg.colorTo: ${colorTo}" ${THEMERC}
2022-09-19 20:59:26 +02:00
#sd "\.active.handle.bg.color:.*$" ".active.handle.bg.color: ${1}" ${THEMERC}
sd "^window.active.title.bg.color:.*$" "window.active.title.bg.color: ${1}" ${THEMERC}
sd "^window.active.title.bg.colorTo:.*$" "window.active.title.bg.colorTo: ${2}" ${THEMERC}
2024-09-04 12:58:53 +02:00
## split.To - only used if gradient = splitvertical
splitTo=$(pastel lighten 0.275 "${1}"|pastel format hex)
## 1 color (top one)
sd "window.active.title.bg.color.splitTo:.*$" "window.active.title.bg.color.splitTo: ${splitTo}" ${THEMERC}
splitTo2=$(pastel lighten 0.12 "${2}"|pastel format hex)
#splitTo2=$(pastel lighten 0.09 "${1}"|pastel format hex)
## 4 color (bottom one)
sd "window.active.title.bg.colorTo.splitTo:.*$" "window.active.title.bg.colorTo.splitTo: ${splitTo2}" ${THEMERC}
2022-09-19 20:59:26 +02:00
# Border color = active.title.bg.color (gradient start color)
sd "\.active.border.color:.*$" ".active.border.color: $1" ${THEMERC}
2023-09-23 13:57:32 +02:00
#### INACTIVE
icolor=$(pastel mix -s RGB -f 0.3 ${1} '#000000' |pastel format hex)
icolorTo=$(pastel mix -s RGB -f 0.3 ${2} '#000000' |pastel format hex)
sd "^window.inactive.title.bg.color:.*$" "window.inactive.title.bg.color: ${icolor}" ${THEMERC}
sd "^window.inactive.title.bg.colorTo:.*$" "window.inactive.title.bg.colorTo: ${icolorTo}" ${THEMERC}
# Border color = active.title.bg.color (gradient start color)
sd "\.inactive.border.color:.*$" ".inactive.border.color: ${icolor}" ${THEMERC}
## INACTIVE GRIP and HANDLE
#normalhandle?
###read IBG <<< "$(grep .inactive.title.bg.color: ${THEMERC} | cut -d':' -f2)"
###read IHBG <<< "$(grep .inactive.handle.bg.color: ${THEMERC} | cut -d':' -f2)"
###if [ "$IBG" == "$IHBG" ];then
sd "\.inactive.handle.bg.color:.*$" ".inactive.handle.bg.color: ${icolor}" ${THEMERC}
sd "\.inactive.handle.bg.colorTo:.*$" ".inactive.handle.bg.colorTo: ${icolorTo}" ${THEMERC}
###fi
sd "\.inactive.grip.bg.color:.*$" ".inactive.grip.bg.color: ${icolor}" ${THEMERC}
sd "\.inactive.grip.bg.colorTo:.*$" ".inactive.grip.bg.colorTo: ${icolorTo}" ${THEMERC}
sd "^window.inactive.title.bg.color:.*$" "window.inactive.title.bg.color: ${icolor}" ${THEMERC}
sd "\.inactive.border.color:.*$" ".inactive.border.color: ${icolor}" ${THEMERC}
sd "^window.inactive.title.bg.colorTo:.*$" "window.inactive.title.bg.colorTo: ${icolorTo}" ${THEMERC}
## Active handle always have inactive colors
sd "\.active.handle.bg.color:.*$" ".active.handle.bg.color: ${icolor}" ${THEMERC}
sd "\.active.handle.bg.colorTo:.*$" ".active.handle.bg.colorTo: ${icolorTo}" ${THEMERC}
2022-09-19 20:59:26 +02:00
# calculate color for title.fg and buttons
2022-12-08 17:48:55 +01:00
TITLE_FG=$(pastel textcolor ${2}|pastel format hex)
2022-09-19 20:59:26 +02:00
if [[ "${TITLE_FG}" == *"ffffff"* ]];then
TITLE_FG="#E5E5E5"
2022-09-19 20:59:26 +02:00
else
TITLE_FG="#222222"
2022-09-19 20:59:26 +02:00
fi
sd "\.active.label.text.color:.*$" ".active.label.text.color: ${TITLE_FG}" ${THEMERC}
# Button colors
activebuttonscolors "${TITLE_FG}"
2022-12-19 22:22:23 +01:00
# Shadow
read SHADOW <<< "$(grep .active.label.text.font: ${THEMERC} | cut -d':' -f2| cut -d'=' -f2)"
if [ "$SHADOW" == "y" ];then
if [ "$TITLE_FG" == "#E5E5E5" ];then
2022-12-19 22:22:23 +01:00
shadow dark
else
shadow light
fi
fi
2023-09-23 13:57:32 +02:00
}
gradient () {
sd "^window.active.title.bg.color:.*$" "window.active.title.bg.color: ${1}" ${THEMERC}
sd "^window.active.title.bg.colorTo:.*$" "window.active.title.bg.colorTo: ${2}" ${THEMERC}
2024-09-04 12:58:53 +02:00
## split.To - only used if gradient = splitvertical
splitTo=$(pastel lighten 0.275 "${1}"|pastel format hex)
## 1 color (top one)
sd "window.active.title.bg.color.splitTo:.*$" "window.active.title.bg.color.splitTo: ${splitTo}" ${THEMERC}
splitTo2=$(pastel lighten 0.12 "${2}"|pastel format hex)
#splitTo2=$(pastel lighten 0.09 "${1}"|pastel format hex)
## 4 color (bottom one)
sd "window.active.title.bg.colorTo.splitTo:.*$" "window.active.title.bg.colorTo.splitTo: ${splitTo2}" ${THEMERC}
2023-09-23 13:57:32 +02:00
# Border color = active.title.bg.color (gradient start color)
sd "\.active.border.color:.*$" ".active.border.color: $1" ${THEMERC}
2022-12-19 22:22:23 +01:00
2023-09-23 13:57:32 +02:00
#### INACTIVE
icolor=$(pastel darken 0.5 ${1}|pastel format hex)
icolorTo=$(pastel darken 0.5 ${2}|pastel format hex)
sd "^window.inactive.title.bg.color:.*$" "window.inactive.title.bg.color: ${icolor}" ${THEMERC}
sd "^window.inactive.title.bg.colorTo:.*$" "window.inactive.title.bg.colorTo: ${icolorTo}" ${THEMERC}
# Border color = active.title.bg.color (gradient start color)
sd "\.inactive.border.color:.*$" ".inactive.border.color: ${icolor}" ${THEMERC}
2022-12-19 22:22:23 +01:00
2023-09-23 13:57:32 +02:00
# calculate color for title.fg and buttons
TITLE_FG=$(pastel textcolor ${2}|pastel format hex)
if [[ "${TITLE_FG}" == *"ffffff"* ]];then
TITLE_FG="#E5E5E5"
else
TITLE_FG="#222222"
fi
sd "\.active.label.text.color:.*$" ".active.label.text.color: ${TITLE_FG}" ${THEMERC}
# Button colors
activebuttonscolors "${TITLE_FG}"
# Shadow
read SHADOW <<< "$(grep .active.label.text.font: ${THEMERC} | cut -d':' -f2| cut -d'=' -f2)"
if [ "$SHADOW" == "y" ];then
if [ "$TITLE_FG" == "#E5E5E5" ];then
shadow dark
else
shadow light
fi
fi
2022-09-19 20:59:26 +02:00
}
2023-09-23 13:57:32 +02:00
gradient_reverse () {
2022-09-19 20:59:26 +02:00
:
}
2022-05-15 03:25:01 +02:00
activehandle () {
case "$1" in
no) #no
read NBG <<< "$(grep inactive.title.bg.color: ${THEMERC} | cut -d':' -f2)"
read NBGTO <<< "$(grep inactive.title.bg.colorTo: ${THEMERC} | cut -d':' -f2)"
#notify-send.sh "Normal" "${NBG} ${NBGTO}"
sd "\.active.handle.bg.color:.*$" ".active.handle.bg.color: ${NBG}" ${THEMERC}
sd "\.active.handle.bg.colorTo:.*$" ".active.handle.bg.colorTo: ${NBGTO}" ${THEMERC}
sd "\.active.grip.bg:.*$" ".active.grip.bg: parentrelative" ${THEMERC}
sd "\.active.grip.bg.color:.*$" ".active.grip.bg.color: ${NBG}" ${THEMERC}
sd "\.active.grip.bg.colorTo:.*$" ".active.grip.bg.colorTo: ${NBGTO}" ${THEMERC}
;;
yes) #yes
read ABG <<< "$(grep window.active.title.bg.color: ${THEMERC} | cut -d':' -f2)"
read ABGTO <<< "$(grep window.active.title.bg.colorTo: ${THEMERC} | cut -d':' -f2)"
#notify-send.sh "Active" "${ABG} ${ABGTO}"
sd "\.active.handle.bg.color:.*$" ".active.handle.bg.color: ${ABG}" ${THEMERC}
sd "\.active.handle.bg.colorTo:.*$" ".active.handle.bg.colorTo: ${ABGTO}" ${THEMERC}
sd "\.active.grip.bg:.*$" ".active.grip.bg: parentrelative" ${THEMERC}
sd "\.active.grip.bg.color:.*$" ".active.grip.bg.color: ${ABG}" ${THEMERC}
sd "\.active.grip.bg.colorTo:.*$" ".active.grip.bg.colorTo: ${ABGTO}" ${THEMERC}
;;
grip)
read GRAD <<< "$(grep .title.bg: ${THEMERC} | cut -d':' -f2)"
read ABG <<< "$(grep window.active.title.bg.color: ${THEMERC} | cut -d':' -f2)"
read ABGTO <<< "$(grep window.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)"
sd "\.active.grip.bg:.*$" ".active.grip.bg: ${GRAD}" ${THEMERC}
sd "\.active.grip.bg.color:.*$" ".active.grip.bg.color: ${ABG}" ${THEMERC}
sd "\.active.grip.bg.colorTo:.*$" ".active.grip.bg.colorTo: ${ABGTO}" ${THEMERC}
sd "\.active.handle.bg.color:.*$" ".active.handle.bg.color: ${NBG}" ${THEMERC}
sd "\.active.handle.bg.colorTo:.*$" ".active.handle.bg.colorTo: ${NBGTO}" ${THEMERC}
;;
esac
}
2023-01-05 19:28:22 +01:00
clractivebg_only () {
sd "^window.active.title.bg.color:.*$" "window.active.title.bg.color: ${1}" ${THEMERC}
# calculate color for title.fg and buttons
TITLE_FG=$(pastel textcolor ${1}|pastel format hex)
if [[ "${TITLE_FG}" == *"ffffff"* ]];then
TITLE_FG="#E5E5E5"
2023-01-05 19:28:22 +01:00
else
TITLE_FG="#222222"
2023-01-05 19:28:22 +01:00
fi
sd "\.active.label.text.color:.*$" ".active.label.text.color: ${TITLE_FG}" ${THEMERC}
# Button colors
activebuttonscolors "${TITLE_FG}"
}
2022-05-15 03:25:01 +02:00
clractivebg () {
2024-09-04 12:58:53 +02:00
colorTo=$(pastel darken 0.14 "${1}"|pastel format hex)
2022-05-15 03:25:01 +02:00
#activehandle?
read ABG <<< "$(grep .active.title.bg.color: ${THEMERC} | cut -d':' -f2)"
read AHBG <<< "$(grep .active.handle.bg.color: ${THEMERC} | cut -d':' -f2)"
if [ "$ABG" == "$AHBG" ];then
sd "\.active.handle.bg.color:.*$" ".active.handle.bg.color: ${1}" ${THEMERC}
sd "\.active.handle.bg.colorTo:.*$" ".active.handle.bg.colorTo: ${colorTo}" ${THEMERC}
fi
sd "\.active.grip.bg.color:.*$" ".active.grip.bg.color: ${1}" ${THEMERC}
sd "\.active.grip.bg.colorTo:.*$" ".active.grip.bg.colorTo: ${colorTo}" ${THEMERC}
sd "^window.active.title.bg.color:.*$" "window.active.title.bg.color: ${1}" ${THEMERC}
sd "\.active.border.color:.*$" ".active.border.color: ${1}" ${THEMERC}
sd "^window.active.title.bg.colorTo:.*$" "window.active.title.bg.colorTo: ${colorTo}" ${THEMERC}
2024-09-04 12:58:53 +02:00
## split.To - only used if gradient = splitvertical
splitTo=$(pastel lighten 0.275 "${1}"|pastel format hex)
## 1 color (top one)
sd "window.active.title.bg.color.splitTo:.*$" "window.active.title.bg.color.splitTo: ${splitTo}" ${THEMERC}
splitTo2=$(pastel lighten 0.12 "${colorTo}"|pastel format hex)
#splitTo2=$(pastel lighten 0.09 "${1}"|pastel format hex)
## 4 color (bottom one)
sd "window.active.title.bg.colorTo.splitTo:.*$" "window.active.title.bg.colorTo.splitTo: ${splitTo2}" ${THEMERC}
2022-06-29 16:31:14 +02:00
#menu (Openbox menu - not really used in Mabox)
sd "menu.title.bg.color:.*$" "menu.title.bg.color: ${1}" ${THEMERC}
sd "menu.title.bg.colorTo:.*$" "menu.title.bg.colorTo: ${colorTo}" ${THEMERC}
sd "menu.items.active.bg.color:.*$" "menu.items.active.bg.color: ${1}" ${THEMERC}
sd "menu.items.active.bg.colorTo:.*$" "menu.items.active.bg.colorTo: ${colorTo}" ${THEMERC}
2022-12-08 17:48:55 +01:00
# calculate color for title.fg and buttons
TITLE_FG=$(pastel textcolor ${colorTo}|pastel format hex)
if [[ "${TITLE_FG}" == *"ffffff"* ]];then
TITLE_FG="#E5E5E5"
2022-12-08 17:48:55 +01:00
else
TITLE_FG="#222222"
2022-12-08 17:48:55 +01:00
fi
sd "\.active.label.text.color:.*$" ".active.label.text.color: ${TITLE_FG}" ${THEMERC}
# Button colors
activebuttonscolors "${TITLE_FG}"
2022-05-15 03:25:01 +02:00
}
2022-09-19 20:59:26 +02:00
2023-01-05 19:28:22 +01:00
clrnormalbg_only () {
sd "^window.inactive.title.bg.color:.*$" "window.inactive.title.bg.color: ${1}" ${THEMERC}
}
2022-05-15 03:25:01 +02:00
clrnormalbg () {
colorTo=$(pastel darken 0.1 "${1}"|pastel format hex)
2023-09-23 13:57:32 +02:00
###sd "\.inactive.handle.bg.color:.*$" ".inactive.handle.bg.color: ${1}" ${THEMERC}
###sd "\.inactive.handle.bg.colorTo:.*$" ".inactive.handle.bg.colorTo: ${colorTo}" ${THEMERC}
sd "\.handle.bg.color:.*$" ".handle.bg.color: ${1}" ${THEMERC}
sd "\.handle.bg.colorTo:.*$" ".handle.bg.colorTo: ${colorTo}" ${THEMERC}
2022-05-15 03:25:01 +02:00
sd "\.inactive.grip.bg.color:.*$" ".inactive.grip.bg.color: ${1}" ${THEMERC}
sd "\.inactive.grip.bg.colorTo:.*$" ".inactive.grip.bg.colorTo: ${colorTo}" ${THEMERC}
sd "^window.inactive.title.bg.color:.*$" "window.inactive.title.bg.color: ${1}" ${THEMERC}
sd "^window.inactive.title.bg.colorTo:.*$" "window.inactive.title.bg.colorTo: ${colorTo}" ${THEMERC}
2024-09-04 12:58:53 +02:00
## split.To - only used if gradient = splitvertical
splitTo=$(pastel lighten 0.275 "${1}"|pastel format hex)
## 1 color (top one)
sd "window.inactive.title.bg.color.splitTo:.*$" "window.inactive.title.bg.color.splitTo: ${splitTo}" ${THEMERC}
splitTo2=$(pastel lighten 0.12 "${colorTo}"|pastel format hex)
#splitTo2=$(pastel lighten 0.09 "${1}"|pastel format hex)
## 4 color (bottom one)
sd "window.inactive.title.bg.colorTo.splitTo:.*$" "window.inactive.title.bg.colorTo.splitTo: ${splitTo2}" ${THEMERC}
2023-09-23 13:57:32 +02:00
sd "\.inactive.border.color:.*$" ".inactive.border.color: ${1}" ${THEMERC}
2022-05-15 03:25:01 +02:00
}
2022-09-19 20:59:26 +02:00
2022-05-15 03:25:01 +02:00
clractivebgto () {
sd "^window.active.title.bg.colorTo:.*$" "window.active.title.bg.colorTo: ${1}" ${THEMERC}
2024-09-04 12:58:53 +02:00
splitTo2=$(pastel lighten 0.12 "${1}"|pastel format hex)
#splitTo2=$(pastel lighten 0.09 "${1}"|pastel format hex)
## 4 color (bottom one)
sd "window.active.title.bg.colorTo.splitTo:.*$" "window.active.title.bg.colorTo.splitTo: ${splitTo2}" ${THEMERC}
2022-05-15 03:25:01 +02:00
#activehandle?
2023-09-23 13:57:32 +02:00
###read ABG <<< "$(grep .active.title.bg.color: ${THEMERC} | cut -d':' -f2)"
###read AHBG <<< "$(grep .active.handle.bg.color: ${THEMERC} | cut -d':' -f2)"
###if [ "$ABG" == "$AHBG" ];then
2022-05-15 03:25:01 +02:00
sd "\.active.handle.bg.colorTo:.*$" ".active.handle.bg.colorTo: ${1}" ${THEMERC}
2023-09-23 13:57:32 +02:00
###fi
2022-05-15 03:25:01 +02:00
sd "\.active.grip.bg.colorTo:.*$" ".active.grip.bg.colorTo: ${1}" ${THEMERC}
}
2022-09-19 20:59:26 +02:00
2022-05-15 03:25:01 +02:00
clrnormalbgto () {
sd "^window.inactive.title.bg.colorTo:.*$" "window.inactive.title.bg.colorTo: ${1}" ${THEMERC}
2024-09-04 12:58:53 +02:00
splitTo2=$(pastel lighten 0.12 "${1}"|pastel format hex)
#splitTo2=$(pastel lighten 0.09 "${1}"|pastel format hex)
## 4 color (bottom one)
sd "window.active.title.bg.colorTo.splitTo:.*$" "window.active.title.bg.colorTo.splitTo: ${splitTo2}" ${THEMERC}
2022-05-15 03:25:01 +02:00
sd "\.inactive.handle.bg.colorTo:.*$" ".inactive.handle.bg.colorTo: ${1}" ${THEMERC}
sd "\.inactive.grip.bg.colorTo:.*$" ".inactive.grip.bg.colorTo: ${1}" ${THEMERC}
}
activetextcolor () {
sd "\.active.label.text.color:.*$" ".active.label.text.color: ${1}" ${THEMERC}
2022-12-19 22:22:23 +01:00
activebuttonscolors ${1}
2022-05-15 03:25:01 +02:00
}
inactivetextcolor () {
sd "\.inactive.label.text.color:.*$" ".inactive.label.text.color: ${1}" ${THEMERC}
}
2022-06-04 22:50:37 +02:00
buttons () {
rm $THEMEDIR/*.xbm
cp -a /usr/share/mabox-colorizer/themes/obbuttons/${1}/*.xbm $THEMEDIR/
2023-09-08 12:34:28 +02:00
#save buttons name to file
echo "${1}" > $THEMEDIR/.buttons
2023-07-28 17:07:31 +02:00
#if buttons big check font size also
case "$1" in
big-12)
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
SIZE=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' "$cfg")
if [ "$SIZE" -lt "12" ]; then
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' -v "12" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:size' -v "12" "$cfg"
fi
;;
big-14)
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
SIZE=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' "$cfg")
if [ "$SIZE" -lt "14" ]; then
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' -v "14" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:size' -v "14" "$cfg"
2023-07-28 17:07:31 +02:00
fi
;;
*) : ;;
esac
2022-09-19 20:59:26 +02:00
}
ndslimc() {
xmlstarlet ed -L -N o="http://openbox.org/3.4/rc" -u '/o:openbox_config/o:theme/o:titleLayout' -v "$1" "$HOME/.config/openbox/rc.xml"
}
2022-09-19 20:59:26 +02:00
activebuttonscolors () {
sd "^window.active.button.*.unpressed.image.color:.*$" "window.active.button.*.unpressed.image.color: ${1}" ${THEMERC}
# Calculate colors for other button states (mix of ${1} and clractivebg
#read ABG <<< "$(grep .active.title.bg.color: ${THEMERC} | cut -d':' -f2)"
#hover=$(pastel mix -f 0.2 "${1}" "${ABG}"|pastel format hex)
2022-09-19 20:59:26 +02:00
#pressed=$()
#disabled=$()
if [[ "${1}" == *"E5E5E5"* ]];then
hover="#FFFFFF"
else
hover="#000000"
fi
#notify-send.sh "${1}" "${hover}"
2022-09-19 20:59:26 +02:00
sd "^window.active.button.*.hover.image.color:.*$" "window.active.button.*.hover.image.color: ${hover}" ${THEMERC}
2022-06-04 22:50:37 +02:00
}
2022-12-19 22:22:23 +01:00
fontfamily () {
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:name' -v "${1}" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:name' -v "${1}" "$cfg"
}
2022-12-08 17:48:55 +01:00
fontsize () {
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
case "$1" in
2023-08-30 14:00:09 +02:00
inc|increase)
2022-12-08 17:48:55 +01:00
SIZE=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' "$cfg")
2022-12-17 12:12:52 +01:00
if [ "$SIZE" -lt "21" ];then
2022-12-08 17:48:55 +01:00
((SIZE=SIZE+1))
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' -v "$SIZE" "$cfg"
2022-12-17 12:12:52 +01:00
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:size' -v "$SIZE" "$cfg"
fi
2022-12-08 17:48:55 +01:00
;;
2023-08-30 14:00:09 +02:00
dec|decrease)
2022-12-08 17:48:55 +01:00
SIZE=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' "$cfg")
2022-12-17 12:12:52 +01:00
if [ "$SIZE" -gt "7" ];then
((SIZE=SIZE-1))
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' -v "$SIZE" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:size' -v "$SIZE" "$cfg"
fi
2022-12-08 17:48:55 +01:00
;;
*)
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' -v "$1" "$cfg"
2022-12-17 12:12:52 +01:00
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:size' -v "$1" "$cfg"
2022-12-08 17:48:55 +01:00
;;
esac
}
2022-12-19 22:22:23 +01:00
fontweight () {
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' -v "${1}" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:weight' -v "${1}" "$cfg"
}
2024-02-22 14:24:51 +01:00
fontweight_inactive () {
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:weight' -v "${1}" "$cfg"
}
2022-12-08 17:48:55 +01:00
fontweighttoggle (){
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
WEIGHT=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' "$cfg")
if [ "$WEIGHT" = "Normal" ];then
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' -v "Bold" "$cfg"
else
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' -v "Normal" "$cfg"
fi
}
2022-12-19 22:22:23 +01:00
fontslant (){
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' -v "${1}" "$cfg"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:slant' -v "${1}" "$cfg"
}
2024-02-22 14:24:51 +01:00
fontslant_inactive (){
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:slant' -v "${1}" "$cfg"
}
2022-12-08 17:48:55 +01:00
fontslanttoggle (){
nspace="http://openbox.org/3.4/rc"
cfg="$HOME/.config/openbox/rc.xml"
SLANT=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' "$cfg")
if [ "$SLANT" = "Normal" ];then
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' -v "Italic" "$cfg"
else
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' -v "Normal" "$cfg"
fi
}
2022-12-19 22:22:23 +01:00
randomizer () {
2023-07-25 14:23:08 +02:00
# TODO: - maybe put all options to cnf file and let users customize options???
2022-12-19 22:22:23 +01:00
### ensure we use MBColors at the moment
theme MBcolors
### SHADOW (here, because we must know if is set later when title font color is calculated)
2023-05-10 23:50:21 +02:00
### Maybe better is not to change shadow? for now
#SHADOWS=(no dark light)
#rand=$((RANDOM%3))
#SHADOW="${SHADOWS[$rand]}"
2022-12-19 22:22:23 +01:00
2023-05-10 23:50:21 +02:00
#shadow "${SHADOW}"
2023-05-14 14:34:17 +02:00
shadow no
2022-12-19 22:22:23 +01:00
### RANDOM GRADIENT COLORS
GRADIENT_FILE="$HOME"/.config/colorizer/gradients_all.inc
if [ ! -f $GRADIENT_FILE ]; then
cp -a /usr/share/mabox-colorizer/gradients_all.inc $GRADIENT_FILE
fi
read CLR CLRTO GRAD_NAME <<< "$(shuf -n 1 $GRADIENT_FILE)"
#obtctl random_gradient
activegradient "$CLR" "$CLRTO"
### rand gradient type
2023-09-25 13:37:33 +02:00
TYPES=(solid vertical horizontal mirrorhorizontal diagonal mirrorhorizontal)
2023-08-30 14:00:09 +02:00
rand=$((RANDOM%6))
2022-12-19 22:22:23 +01:00
G_TYPE="${TYPES[$rand]}"
gradient_type "${G_TYPE}"
#rand
### Random border
2024-02-22 14:24:51 +01:00
BORDERS=(0 0 1 2 4 6)
rand=$((RANDOM%5))
2022-12-19 22:22:23 +01:00
BORDER="${BORDERS[$rand]}"
borderWidth "${BORDER}"
2023-09-25 13:37:33 +02:00
HANDLES=(0 0 2 4)
rand=$((RANDOM%4))
HANDLE="${HANDLES[$rand]}"
handlewidth "${HANDLE}"
2022-12-19 22:22:23 +01:00
### Random padding
2023-08-30 14:00:09 +02:00
PADDINGS=(2 4 8 12)
2022-12-19 22:22:23 +01:00
rand=$((RANDOM%4))
PADDING="${PADDINGS[$rand]}"
paddingHeight "${PADDING}"
### TITLEBAR STYLE
2023-09-25 13:37:33 +02:00
STYLES=(flat raised raised sunken)
rand=$((RANDOM%4))
2022-12-19 22:22:23 +01:00
STYLE="${STYLES[$rand]}"
raised "${STYLE}"
2023-08-30 14:00:09 +02:00
2022-12-19 22:22:23 +01:00
### TEXT ALIGN
ALIGNS=(left center right)
rand=$((RANDOM%3))
ALIGN="${ALIGNS[$rand]}"
textjustify "${ALIGN}"
### FONT FAMILY
2023-08-30 14:00:09 +02:00
FAMILIES=(Ubuntu "Noto Sans" "Roboto Condensed" "GE Inspira" "JetBrains Mono")
rand=$((RANDOM%5))
2022-12-19 22:22:23 +01:00
FAMILY="${FAMILIES[$rand]}"
fontfamily "${FAMILY}"
### FONT WEIGHT
WEIGHTS=(Bold Normal)
rand=$((RANDOM%2))
WEIGHT="${WEIGHTS[$rand]}"
fontweight "${WEIGHT}"
### FONT SLANT
SLANTS=(Italic Normal)
rand=$((RANDOM%2))
SLANT="${SLANTS[$rand]}"
fontslant "${SLANT}"
### FONT SIZE
FONTSIZES=(8 10 11 12 14 16)
rand=$((RANDOM%6))
FONTSIZE="${FONTSIZES[$rand]}"
fontsize "${FONTSIZE}"
2023-08-30 14:00:09 +02:00
### Buttons
BUTTONS=(tiny normal bold dots big-12 big-14)
rand=$((RANDOM%6))
BUTTON="${BUTTONS[$rand]}"
buttons "${BUTTON}"
2023-09-25 13:37:33 +02:00
### Buttons layout
LAYOUTS=(NDSLIMC NDSLIMC NLIMC LIMC)
rand=$((RANDOM%4))
LAYOUT="${LAYOUTS[$rand]}"
ndslimc "${LAYOUT}"
2022-12-19 22:22:23 +01:00
2022-12-20 09:46:47 +01:00
#MSG="
#Openbox Window Decoration settings
#Gradient
#name: <b>${GRAD_NAME}</b>
#colors: <b>${CLR}</b> to <b>${CLRTO}</b>
#type: <b>$G_TYPE</b>
2022-12-19 22:22:23 +01:00
2022-12-20 09:46:47 +01:00
#Border: <b>${BORDER}</b>
#Padding: <b>${PADDING}</b>
2022-12-19 22:22:23 +01:00
2022-12-20 09:46:47 +01:00
#Titlebar style: <b>${STYLE}</b>
#Buttons: <b>${BUTTON}</b>
#Title align: <b>${ALIGN}</b>
#Font: <b>${FAMILY} ${WEIGHT} ${SLANT} ${FONTSIZE}</b>
#"
# notify-send.sh -R /tmp/randomizer_notify -t 10000 -i mbcc "Mabox Colorizer" "${MSG}" \
2023-09-25 13:37:33 +02:00
# -o "Regenerate:randomizer ob" -o "Customize:colorizer-ob -s"
2022-12-19 22:22:23 +01:00
}
2022-05-15 03:25:01 +02:00
2023-09-23 13:57:32 +02:00
tweak() {
case "$1" in
large)
fontsize 14
paddingHeight 8
buttons big-14
2024-02-22 14:24:51 +01:00
borderWidth 6
2023-09-23 13:57:32 +02:00
handlewidth 6
;;
big)
fontsize 12
paddingHeight 6
buttons big-12
2024-02-22 14:24:51 +01:00
borderWidth 4
2023-09-23 13:57:32 +02:00
handlewidth 4
;;
normal)
fontsize 11
paddingHeight 4
buttons tiny
2024-02-22 14:24:51 +01:00
borderWidth 1
2023-09-23 13:57:32 +02:00
handlewidth 3
;;
small)
fontsize 10
paddingHeight 2
buttons dots
borderWidth 0
handlewidth 2
;;
tiny)
fontsize 9
paddingHeight 1
buttons normal
borderWidth 0
handlewidth 0
;;
*):;;
esac
}
savetheme () {
case "$LANG" in
pl*)SAVE_AS="Nowy motyw Openbox"
DESC="Zapisz obecne ustawionia Openbox jako nowy motyw..."
LABEL="Nazwa:"
NAME="nazwa";;
*) SAVE_AS="New Openbox theme"
DESC="Save current Openbox window decoration setup as theme..."
LABEL="Name:"
NAME="theme-name";;
esac
# ask for scheme name
schemename=$(yad --center --width=300 --borders=20 --window-icon=mbcc --title "$SAVE_AS" --text="$DESC" --entry --entry-label="$LABEL" --entry-text="$NAME") || exit 1
echo "${1}${schemename}" >> "$HOME/.config/colorizer/openbox/userthemes.csv"
}
applyscheme () {
theme MBcolors
case "$1" in
sys) SCHEMEFILE="/usr/share/mabox-colorizer/colorschemes/ob.csv";;
usr) SCHEMEFILE="$HOME/.config/colorizer/openbox/userthemes.csv";;
esac
while IFS="|" read -r abg abgto afg aline nbg nbgto nfg nline grad txtjust pheight pwidth handle bord bevel button fsize fname ndslim weight slant scheme_name
do
clractivebg "${abg}"
clractivebgto "${abgto}"
activetextcolor "${afg}"
activeborderColor "${aline}"
clrnormalbg "${nbg}"
clrnormalbgto "${nbgto}"
inactivetextcolor "${nfg}"
inactiveborderColor "${nline}"
gradient_type "${grad}"
done < <(awk 'NR == n' n=$2 "$SCHEMEFILE")
}
applytheme() {
case "$1" in
sys) SCHEMEFILE="/usr/share/mabox-colorizer/colorschemes/ob.csv";;
usr) SCHEMEFILE="$HOME/.config/colorizer/openbox/userthemes.csv";;
esac
applyscheme "$1" "$2"
while IFS="|" read -r abg abgto afg aline nbg nbgto nfg nline grad txtjust pheight pwidth handle bord bevel button fsize fname ndslim weight slant scheme_name
do
textjustify "${txtjust}"
paddingHeight "${pheight}"
paddingWidth "${pwidth}"
handlewidth "${handle}"
borderWidth "${bord}"
raised "${bevel}"
buttons "${button}"
fontsize "${fsize}"
fontfamily "${fname}"
ndslimc "${ndslim}"
fontweight "${weight}"
fontslant "${slant}"
done < <(awk 'NR == n' n=$2 "$SCHEMEFILE")
}
delscheme() {
sed -i ${1}d "$HOME/.config/colorizer/openbox/userthemes.csv"
}
2024-02-22 14:24:51 +01:00
mono() {
lighten=(0.92 0.8 0.65 0.45 0.28)
darken=(0.9 0.74 0.54 0.38 0.18)
if [ "${1}" == pick ];then
color=$(gpick -pso 2>/dev/null)
else
color="${1}"
fi
if [ "${#color}" == 7 ];then
for i in "${lighten[@]}"
do
pal+=("$(pastel mix -f $i "#ffffff" "$color"|pastel format hex)")
done
pal+=("$color")
for i in "${darken[@]}"
do
pal+=("$(pastel mix -f $i "$color" "#000000"|pastel format hex)")
done
else
exit 0
fi
#colorize OB
if [ "$2" == "dark" ];then
2024-09-04 12:58:53 +02:00
clractivebg "${pal[5]}"
#clractivebgto "${pal[6]}"
2024-02-22 14:24:51 +01:00
activeborderColor "${pal[2]}"
activetextcolor "${pal[1]}"
clrnormalbg "${pal[9]}"
clrnormalbgto "${pal[10]}"
inactiveborderColor "${pal[8]}"
inactivetextcolor "${pal[4]}"
else #light
2024-09-04 12:58:53 +02:00
clractivebg "${pal[4]}"
#clractivebgto "${pal[4]}"
2024-02-22 14:24:51 +01:00
activeborderColor "${pal[0]}"
activetextcolor "${pal[9]}"
clrnormalbg "${pal[9]}"
clrnormalbgto "${pal[10]}"
inactiveborderColor "${pal[7]}"
inactivetextcolor "${pal[5]}"
fi
openbox --reconfigure
colorizer-ob -s 2>/dev/null
}
2023-09-23 13:57:32 +02:00
2022-05-15 03:25:01 +02:00
case "$1" in
theme) theme "$2";;
reset) reset;;
2022-12-23 11:10:27 +01:00
resetonlycolors) resetonlycolors;;
2022-12-17 12:12:52 +01:00
resetMBcolors) resetMBcolors;;
2022-05-15 03:25:01 +02:00
borderWidth) borderWidth "$2";;
activeborderColor) activeborderColor "$2";;
inactiveborderColor) inactiveborderColor "$2";;
paddingHeight) paddingHeight "$2";;
paddingWidth) paddingWidth "$2";;
textjustify) textjustify "$2";;
shadow) shadow "$2";;
handlewidth) handlewidth "$2";;
raised) raised "$2";;
2022-12-19 22:22:23 +01:00
gradient_type) gradient_type "$2";;
random_gradient) random_gradient;;
2022-09-19 20:59:26 +02:00
activegradient) activegradient "$2" "$3";;
2023-09-23 13:57:32 +02:00
gradient_reverse) gradient_reverse;;
2022-09-19 20:59:26 +02:00
activehandle) activehandle "$2";;
2023-01-05 19:28:22 +01:00
clractivebg_only) clractivebg_only "$2";; #ADVANCED - do not calculate colorTo
2022-05-15 03:25:01 +02:00
clractivebg) clractivebg "$2";;
clractivebgto) clractivebgto "$2";;
2023-01-05 19:28:22 +01:00
clrnormalbg_only) clrnormalbg_only "$2";;
2022-05-15 03:25:01 +02:00
clrnormalbg) clrnormalbg "$2";;
clrnormalbgto) clrnormalbgto "$2";;
activetextcolor) activetextcolor "$2";;
inactivetextcolor) inactivetextcolor "$2";;
2022-06-04 22:50:37 +02:00
buttons) buttons "$2";;
ndslimc) ndslimc "$2";;
2022-09-19 20:59:26 +02:00
activebuttonscolors) activebuttonscolors "$2";;
2022-12-19 22:22:23 +01:00
fontfamily) fontfamily "$2";;
fontweight) fontweight "$2";;
2024-02-22 14:24:51 +01:00
fontweight_inactive) fontweight_inactive "$2";;
2022-12-19 22:22:23 +01:00
fontslant) fontslant "$2";;
2024-02-22 14:24:51 +01:00
fontslant_inactive) fontslant_inactive "$2";;
2022-12-08 17:48:55 +01:00
fontsize) fontsize "$2";;
fontweighttoggle) fontweighttoggle;;
fontslanttoggle) fontslanttoggle;;
2022-12-19 22:22:23 +01:00
randomizer) randomizer;;
2023-09-23 13:57:32 +02:00
tweak) tweak "$2";;
2024-02-22 14:24:51 +01:00
mono) mono "$2" "$3";;
2023-09-23 13:57:32 +02:00
savetheme) savetheme "$2";;
applyscheme) applyscheme "$2" "$3";;
applytheme) applytheme "$2" "$3";;
delscheme) delscheme "$2";;
2022-05-15 03:25:01 +02:00
*) : ;;
esac
2022-09-19 20:59:26 +02:00
openbox --reconfigure