546 lines
21 KiB
Bash
Executable File
546 lines
21 KiB
Bash
Executable File
#!/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"
|
|
|
|
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
|
|
|
|
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}
|
|
}
|
|
resetMBcolors() {
|
|
theme MBcolors
|
|
rsync -a /usr/share/mabox-colorizer/themes/MBcolors/openbox-3/* ${MBCOLORSDIR}/
|
|
#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"
|
|
}
|
|
|
|
borderWidth () {
|
|
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
|
|
;;
|
|
0|1|2|3|4|5|6|7|8)
|
|
sd "^border.width:.*$" "border.width: $1" ${THEMERC}
|
|
;;
|
|
esac
|
|
}
|
|
activeborderColor () {
|
|
sd "\.active.border.color:.*$" ".active.border.color: $1" ${THEMERC}
|
|
}
|
|
inactiveborderColor () {
|
|
sd "\.inactive.border.color:.*$" ".inactive.border.color: $1" ${THEMERC}
|
|
}
|
|
paddingHeight () {
|
|
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
|
|
;;
|
|
0|1|2|3|4|6|8|10|12|16|20)
|
|
sd "^padding.height:.*$" "padding.height: $1" ${THEMERC}
|
|
sd "^padding.width:.*$" "padding.width: $1" ${THEMERC}
|
|
;;
|
|
esac
|
|
|
|
}
|
|
paddingWidth () {
|
|
sd "^padding.width:.*$" "padding.width: $1" ${THEMERC}
|
|
}
|
|
textjustify () {
|
|
sd "\.text.justify:.*$" ".text.justify: $1" ${THEMERC}
|
|
}
|
|
shadow () {
|
|
case "$1" in
|
|
0|no)
|
|
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}
|
|
;;
|
|
1|dark)
|
|
sd "\.active.label.text.font:.*$" ".active.label.text.font: shadow=y:shadowtint=70:shadowoffset=1" ${THEMERC}
|
|
#sd "\.inactive.label.text.font:.*$" ".inactive.label.text.font: shadow=y:shadowtint=20:shadowoffset=1" ${THEMERC}
|
|
;;
|
|
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}
|
|
;;
|
|
esac
|
|
|
|
}
|
|
handlewidth () {
|
|
sd "\.handle.width:.*$" ".handle.width: $1" ${THEMERC}
|
|
}
|
|
raised () {
|
|
#flat 0 or raised 1 or sunken 2
|
|
read WINRAISED REST <<< "$(grep .title.bg: ${THEMERC} | cut -d':' -f2)"
|
|
case "$1" in
|
|
0|flat)
|
|
sd "\.title.bg:.*$" ".title.bg: flat ${REST}" ${THEMERC}
|
|
sd "\.handle.bg:.*$" ".handle.bg: flat ${REST}" ${THEMERC}
|
|
sd "\.grip.bg:.*$" ".grip.bg: flat ${REST}" ${THEMERC}
|
|
;;
|
|
1|raised)
|
|
sd "\.title.bg:.*$" ".title.bg: raised ${REST}" ${THEMERC}
|
|
sd "\.handle.bg:.*$" ".handle.bg: raised ${REST}" ${THEMERC}
|
|
sd "\.grip.bg:.*$" ".grip.bg: raised ${REST}" ${THEMERC}
|
|
;;
|
|
2|sunken)
|
|
sd "\.title.bg:.*$" ".title.bg: sunken ${REST}" ${THEMERC}
|
|
sd "\.handle.bg:.*$" ".handle.bg: sunken ${REST}" ${THEMERC}
|
|
sd "\.grip.bg:.*$" ".grip.bg: sunken ${REST}" ${THEMERC}
|
|
;;
|
|
esac
|
|
}
|
|
gradient_type () {
|
|
#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}
|
|
;;
|
|
*)
|
|
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}
|
|
;;
|
|
esac
|
|
}
|
|
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"
|
|
}
|
|
activegradient () {
|
|
#notify-send.sh "zmiennne obtctl" "${1} ${2}"
|
|
#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}
|
|
|
|
# Border color = active.title.bg.color (gradient start color)
|
|
sd "\.active.border.color:.*$" ".active.border.color: $1" ${THEMERC}
|
|
|
|
# calculate color for title.fg and buttons
|
|
TITLE_FG=$(pastel textcolor ${2}|pastel format hex)
|
|
if [[ "${TITLE_FG}" == *"ffffff"* ]];then
|
|
TITLE_FG="#EEEEEE"
|
|
else
|
|
TITLE_FG="#111111"
|
|
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" == "#EEEEEE" ];then
|
|
shadow dark
|
|
else
|
|
shadow light
|
|
fi
|
|
fi
|
|
|
|
|
|
}
|
|
activegradient_reverse () {
|
|
:
|
|
}
|
|
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
|
|
}
|
|
|
|
clractivebg () {
|
|
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
|
|
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}
|
|
#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}
|
|
|
|
# calculate color for title.fg and buttons
|
|
TITLE_FG=$(pastel textcolor ${colorTo}|pastel format hex)
|
|
if [[ "${TITLE_FG}" == *"ffffff"* ]];then
|
|
TITLE_FG="#EEEEEE"
|
|
else
|
|
TITLE_FG="#111111"
|
|
fi
|
|
sd "\.active.label.text.color:.*$" ".active.label.text.color: ${TITLE_FG}" ${THEMERC}
|
|
|
|
# Button colors
|
|
activebuttonscolors "${TITLE_FG}"
|
|
|
|
}
|
|
|
|
clrnormalbg () {
|
|
colorTo=$(pastel darken 0.1 "${1}"|pastel format hex)
|
|
#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: ${1}" ${THEMERC}
|
|
sd "\.inactive.handle.bg.colorTo:.*$" ".inactive.handle.bg.colorTo: ${colorTo}" ${THEMERC}
|
|
fi
|
|
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 "\.inactive.border.color:.*$" ".inactive.border.color: ${1}" ${THEMERC}
|
|
sd "^window.inactive.title.bg.colorTo:.*$" "window.inactive.title.bg.colorTo: ${colorTo}" ${THEMERC}
|
|
}
|
|
|
|
clractivebgto () {
|
|
sd "^window.active.title.bg.colorTo:.*$" "window.active.title.bg.colorTo: ${1}" ${THEMERC}
|
|
#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.colorTo:.*$" ".active.handle.bg.colorTo: ${1}" ${THEMERC}
|
|
fi
|
|
sd "\.active.grip.bg.colorTo:.*$" ".active.grip.bg.colorTo: ${1}" ${THEMERC}
|
|
}
|
|
|
|
clrnormalbgto () {
|
|
sd "^window.inactive.title.bg.colorTo:.*$" "window.inactive.title.bg.colorTo: ${1}" ${THEMERC}
|
|
#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.colorTo:.*$" ".inactive.handle.bg.colorTo: ${1}" ${THEMERC}
|
|
fi
|
|
sd "\.inactive.grip.bg.colorTo:.*$" ".inactive.grip.bg.colorTo: ${1}" ${THEMERC}
|
|
}
|
|
activetextcolor () {
|
|
sd "\.active.label.text.color:.*$" ".active.label.text.color: ${1}" ${THEMERC}
|
|
activebuttonscolors ${1}
|
|
}
|
|
inactivetextcolor () {
|
|
sd "\.inactive.label.text.color:.*$" ".inactive.label.text.color: ${1}" ${THEMERC}
|
|
}
|
|
buttons () {
|
|
rm $THEMEDIR/*.xbm
|
|
cp -a /usr/share/mabox-colorizer/themes/obbuttons/${1}/*.xbm $THEMEDIR/
|
|
}
|
|
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)
|
|
#pressed=$()
|
|
#disabled=$()
|
|
sd "^window.active.button.*.hover.image.color:.*$" "window.active.button.*.hover.image.color: ${hover}" ${THEMERC}
|
|
}
|
|
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"
|
|
}
|
|
fontsize () {
|
|
nspace="http://openbox.org/3.4/rc"
|
|
cfg="$HOME/.config/openbox/rc.xml"
|
|
case "$1" in
|
|
increase)
|
|
SIZE=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' "$cfg")
|
|
if [ "$SIZE" -lt "21" ];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
|
|
;;
|
|
decrease)
|
|
SIZE=$(xmlstarlet sel -N a="$nspace" -t -v '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' "$cfg")
|
|
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
|
|
;;
|
|
*)
|
|
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="ActiveWindow"]/a:size' -v "$1" "$cfg"
|
|
xmlstarlet ed -L -N a="$nspace" -u '/a:openbox_config/a:theme/a:font[@place="InactiveWindow"]/a:size' -v "$1" "$cfg"
|
|
;;
|
|
esac
|
|
}
|
|
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"
|
|
|
|
}
|
|
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
|
|
}
|
|
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"
|
|
}
|
|
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
|
|
}
|
|
randomizer () {
|
|
|
|
# TODO: - maybe put all options to cnf file and let users cistomize oprions???
|
|
|
|
### 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)
|
|
SHADOWS=(no dark light)
|
|
rand=$((RANDOM%3))
|
|
SHADOW="${SHADOWS[$rand]}"
|
|
|
|
obtctl shadow "${SHADOW}"
|
|
|
|
### 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
|
|
TYPES=(solid vertical horizontal mirrorhorizontal splitvertical)
|
|
rand=$((RANDOM%5))
|
|
G_TYPE="${TYPES[$rand]}"
|
|
gradient_type "${G_TYPE}"
|
|
#rand
|
|
|
|
### Random border
|
|
BORDERS=(0 1 2 4)
|
|
rand=$((RANDOM%4))
|
|
BORDER="${BORDERS[$rand]}"
|
|
|
|
borderWidth "${BORDER}"
|
|
|
|
### Random padding
|
|
PADDINGS=(2 4 8 12 16)
|
|
rand=$((RANDOM%4))
|
|
PADDING="${PADDINGS[$rand]}"
|
|
|
|
paddingHeight "${PADDING}"
|
|
|
|
### TITLEBAR STYLE
|
|
STYLES=(flat raised sunken)
|
|
rand=$((RANDOM%3))
|
|
STYLE="${STYLES[$rand]}"
|
|
|
|
raised "${STYLE}"
|
|
|
|
### Buttons
|
|
BUTTONS=(tiny normal bold dots)
|
|
rand=$((RANDOM%4))
|
|
BUTTON="${BUTTONS[$rand]}"
|
|
|
|
buttons "${BUTTON}"
|
|
|
|
### TEXT ALIGN
|
|
ALIGNS=(left center right)
|
|
rand=$((RANDOM%3))
|
|
ALIGN="${ALIGNS[$rand]}"
|
|
|
|
textjustify "${ALIGN}"
|
|
|
|
### FONT FAMILY
|
|
FAMILIES=(Ubuntu Sans Serif "Roboto Condensed" "GE Inspira")
|
|
rand=$((RANDOM%5))
|
|
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}"
|
|
|
|
|
|
MSG="
|
|
Openbox Window Decoration settings
|
|
Gradient
|
|
name: <b>${GRAD_NAME}</b>
|
|
colors: <b>${CLR}</b> to <b>${CLRTO}</b>
|
|
type: <b>$G_TYPE</b>
|
|
|
|
Border: <b>${BORDER}</b>
|
|
Padding: <b>${PADDING}</b>
|
|
|
|
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}" \
|
|
-o "Regenerate:randomizer ob" -o "Customize:colorizer-ob -s"
|
|
}
|
|
|
|
case "$1" in
|
|
theme) theme "$2";;
|
|
reset) reset;;
|
|
resetMBcolors) resetMBcolors;;
|
|
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";;
|
|
gradient_type) gradient_type "$2";;
|
|
random_gradient) random_gradient;;
|
|
activegradient) activegradient "$2" "$3";;
|
|
activehandle) activehandle "$2";;
|
|
clractivebg) clractivebg "$2";;
|
|
clractivebgto) clractivebgto "$2";;
|
|
clrnormalbg) clrnormalbg "$2";;
|
|
clrnormalbgto) clrnormalbgto "$2";;
|
|
activetextcolor) activetextcolor "$2";;
|
|
inactivetextcolor) inactivetextcolor "$2";;
|
|
buttons) buttons "$2";;
|
|
activebuttonscolors) activebuttonscolors "$2";;
|
|
fontfamily) fontfamily "$2";;
|
|
fontweight) fontweight "$2";;
|
|
fontslant) fontslant "$2";;
|
|
fontsize) fontsize "$2";;
|
|
fontweighttoggle) fontweighttoggle;;
|
|
fontslanttoggle) fontslanttoggle;;
|
|
randomizer) randomizer;;
|
|
*) : ;;
|
|
esac
|
|
|
|
openbox --reconfigure
|