246 lines
9.5 KiB
Bash
Executable File
246 lines
9.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# colorizer - set of tools for Mabox (auto)theming
|
|
# Copyright (C) 2022-2023 Daniel Napora <napcok@gmail.com>
|
|
#
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
wmctrl -R cavatransparent
|
|
|
|
me="colorizer-cava -s"
|
|
|
|
CFGFILE=~/.config/cava/config
|
|
|
|
# get wallpaper color palette
|
|
WALLPALDIR="$HOME/.cache/colorizer/palettes"
|
|
mkdir -p "$WALLPALDIR"
|
|
read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2)
|
|
|
|
NAME=${WALLPATH////_}
|
|
if [[ "${NAME}" =~ ^_home_.* ]]; then
|
|
n=${#HOME}
|
|
((n++))
|
|
NAME=${NAME:${n}}
|
|
fi
|
|
if [ ! -f "$WALLPALDIR/$NAME.clr" ]; then
|
|
convert ${WALLPATH} -resize 25% -colors 16 -unique-colors txt:- |grep -v '^#'| awk '{print substr($3,1,7)}' |pastel sort-by brightness |pastel format hex > "$WALLPALDIR/$NAME.clr"
|
|
fi
|
|
mapfile -t w < "$WALLPALDIR/$NAME.clr"
|
|
if [[ "${#w[@]}" -lt 8 ]]; then
|
|
w+=("#2e3440" "#4c566a" "#5e81ac" "#bf616b" "#b48ead" "#a3be8c" "#ebcb8b" "#d8dee9" "#eceff4")
|
|
fi
|
|
|
|
case "$LANG" in
|
|
pl*)
|
|
INFO="Cava porady"
|
|
INFO_HEAD="Porady dla Cava"
|
|
INFO_TXT="\n1. Cava jest uruchomiona w przezroczystym oknie...\n \
|
|
Możesz je więc <b>przesuwać</b> lub <b>zmieniać rozmiar</b> tak jak każde inne okno\n \
|
|
<i>Przesuwanie</i>: przytrzymaj <b>Alt</b> i przeciągnij\n \
|
|
<i>Zmiana rozmiaru</i>: przytrzymaj <b>Alt</b> i przeciągnij prawym przyciskiem myszy\n\n \
|
|
2. Użyj strzałek <b> </b>, aby zmienić szerokość słupków"
|
|
COLORIZE_CAVA="Pokoloruj Cava"
|
|
COLOR="Jednolity kolor"
|
|
REVERSE_GRADIENT="Odwróć kolory gradientu"
|
|
START_CAVA="Uruchom Cava"
|
|
GENERATEFROMWP="Generuj z kolorów tapety..."
|
|
LIGHTBG="Jasne do ciemnego"
|
|
DARKBG="Ciemne do jesnego"
|
|
BARS="Słupki"
|
|
BAR_WIDTH="Szerokość słupków"
|
|
BAR_SPACING="Odstęp między słupkami"
|
|
COLOR_MODE="Tryb kolorowania"
|
|
SOLID_COLOR="Jednolity kolor"
|
|
GRADIENT="Gradient"
|
|
PREGRADIENT="Zastosuj gotowy gradient"
|
|
MODGRAD_FROM="Gradient kolor 1"
|
|
MODGRAD_TO="Gradient kolor 2"
|
|
EDITCONF="Edytuj plik konfiguracyjny"
|
|
RELOAD="Przeładuj konfigurację"
|
|
RELOAD_COLORS="Przeładuj kolory"
|
|
;;
|
|
*)
|
|
INFO="CaVa tips & tricks"
|
|
INFO_HEAD="Cava tips & tricks"
|
|
INFO_TXT="\n1. Cava runs inside transparent window...\n \
|
|
So you can <b>move</b> or <b>resize</b> it like any other window\n \
|
|
<i>Move</i>: hold <b>Alt</b> and drag\n \
|
|
<i>Resize</i>: hold <b>Alt</b> and drag with right mouse button\n\n \
|
|
2. Use arrows <b> </b> to change bar width"
|
|
COLORIZE_CAVA="Colorize Cava"
|
|
COLOR="Solid Color"
|
|
REVERSE_GRADIENT="Reverse gradient's colors"
|
|
START_CAVA="Start Cava"
|
|
GENERATEFROMWP="Generate from wallpaper colors..."
|
|
LIGHTBG="Light to Dark"
|
|
DARKBG="Dark to Light"
|
|
BARS="Bars"
|
|
BAR_WIDTH="Bar width"
|
|
BAR_SPACING="Bar spacing"
|
|
COLOR_MODE="Color mode"
|
|
SOLID_COLOR="Solid color"
|
|
GRADIENT="Gradient"
|
|
PREGRADIENT="Apply predefined gradient"
|
|
MODGRAD_FROM="Modify Gradient From"
|
|
MODGRAD_TO="Modify Gradient To"
|
|
EDITCONF="Edit config file"
|
|
RELOAD="Reload config"
|
|
RELOAD_COLORS="Reload colors only"
|
|
|
|
;;
|
|
esac
|
|
|
|
getvalues () {
|
|
read FG <<< "$(grep '.*foreground ' ${CFGFILE} | cut -d"'" -f2)"
|
|
read BW <<< "$(grep '.*bar_width ' ${CFGFILE} | cut -d"=" -f2)"
|
|
read BS <<< "$(grep '.*bar_spacing ' ${CFGFILE} | cut -d"=" -f2)"
|
|
read GR <<< "$(grep '.*gradient ' ${CFGFILE} | cut -d"=" -f2)"
|
|
read GR_FROM <<< "$(grep '.*gradient_color_1 ' ${CFGFILE} | cut -d"'" -f2)"
|
|
read GR_TO <<< "$(grep '.*gradient_color_8 ' ${CFGFILE} | cut -d"'" -f2)"
|
|
|
|
|
|
if [ ${#FG} != 7 ];then
|
|
FGC="#59cc33"
|
|
else
|
|
FGC=${FG}
|
|
fi
|
|
FGT=$(pastel textcolor ${FGC}|pastel format hex)
|
|
}
|
|
getvalues
|
|
out+=("^sep($COLORIZE_CAVA)")
|
|
|
|
out+=("<tt><span bgcolor='$FGC' fgcolor='$FGT'> ${FGC} </span></tt> $COLOR,^pipe(mbclr '$FGC' cavactl foreground Cava_Bar_Color '$me')")
|
|
out+=("^sep($GRADIENT)")
|
|
out+=("<span bgcolor='$GR_FROM'> </span><span bgcolor='$GR_TO'> </span> $PREGRADIENT,^pipe(mbgrad cava)")
|
|
out+=("<span bgcolor='$GR_TO'> </span><span bgcolor='$GR_FROM'> </span> $REVERSE_GRADIENT,cavactl gradient '${GR_TO}' '${GR_FROM}';$me")
|
|
out+=("^sep()")
|
|
out+=("<tt><span bgcolor='$GR_FROM'> </span></tt> $MODGRAD_FROM,^pipe(mbclr '$GR_FROM' cavactl grad_from Cava_Grad_From_Color '$me')")
|
|
out+=("<tt><span bgcolor='$GR_TO'> </span></tt> $MODGRAD_TO,^pipe(mbclr '$GR_TO' cavactl grad_to Cava_Grad_To_Color '$me')")
|
|
out+=("^sep($COLOR_MODE)")
|
|
[[ "$GR" == "0" ]] && out+=("<big>綠</big> $SOLID_COLOR,cavactl mode solid;$me" "<big></big> $GRADIENT,cavactl mode gradient;$me") || out+=("<big></big> $SOLID_COLOR,cavactl mode solid;$me" "<big>綠</big> $GRADIENT,cavactl mode gradient;$me")
|
|
|
|
out+=("^sep(<i>$GENERATEFROMWP</i>)")
|
|
out+=("<span bgcolor='${w[-3]}'> </span><span bgcolor='${w[3]}'> </span> $LIGHTBG,w2theme cava light;$me")
|
|
out+=("<span bgcolor='${w[3]}'> </span><span bgcolor='${w[-3]}'> </span> $DARKBG,w2theme cava dark;$me")
|
|
out+=("^sep($BARS)")
|
|
out+=("$BAR_WIDTH [ <b>$BW</b> ],^checkout(barwidth)")
|
|
out2+=("^tag(barwidth)")
|
|
out2+=("^sep($BAR_WIDTH)")
|
|
for i in 1 2 3 4 5 6 8 10
|
|
do
|
|
out2+=("$i,cavactl bar_width $i;$me")
|
|
done
|
|
|
|
out+=("$BAR_SPACING [ <b>$BS</b> ],^checkout(barspacing)")
|
|
out2+=("^tag(barspacing)")
|
|
out2+=("^sep($BAR_SPACING)")
|
|
for i in 0 1 2 3 4 5 6 8 10
|
|
do
|
|
out2+=("$i,cavactl bar_spacing $i;$me")
|
|
done
|
|
out+=("^sep()")
|
|
out+=(" $EDITCONF,xdg-open ~/.config/cava/config")
|
|
out+=(" $RELOAD,cavactl reload;$me")
|
|
out+=(" $RELOAD_COLORS,cavactl reload_colors;$me")
|
|
out+=("^sep()")
|
|
out+=(" $INFO,notify-send.sh -i music -u critical '$INFO_HEAD' '$INFO_TXT'")
|
|
|
|
|
|
### RUN
|
|
if [[ "$1" == "-s" ]]; then
|
|
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
|
|
. $HOME/.config/mabox/mabox.conf
|
|
|
|
CNF_DIR="$HOME/.config/colorizer"
|
|
CNF_FILE="$CNF_DIR/colorizer.conf"
|
|
source "$CNF_FILE"
|
|
|
|
out+=("^sep()")
|
|
out+=(" ⮜⮜⮜ Colorizer,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 + 158))
|
|
|
|
#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 <<EOF > ${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+100)),12,50,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+20)),$((jgtools_padding+115)),12,35,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+40)),$((jgtools_padding+124)),12,26,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+60)),$((jgtools_padding+114)),12,36,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+80)),$((jgtools_padding+100)),12,50,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+100)),$((jgtools_padding+96)),12,54,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+120)),$((jgtools_padding+74)),12,76,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+140)),$((jgtools_padding+64)),12,86,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+160)),$((jgtools_padding+76)),12,74,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+180)),$((jgtools_padding+94)),12,56,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+200)),$((jgtools_padding+114)),12,36,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+220)),$((jgtools_padding+129)),12,21,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+240)),$((jgtools_padding+119)),12,31,0,left,top,,${clr} 100,
|
|
@rect,,$((jgtools_padding+260)),$((jgtools_padding+110)),10,40,0,left,top,,${clr} 100,
|
|
|
|
@rect,,${jgtools_padding},$((jgtools_padding + 120)),270,28,0,left,top,#222222 20,#222222 70,
|
|
@text,,$((jgtools_padding + 108)),$((jgtools_padding + 120)),120,28,0,left,top,#FFFFFF ,${WINCLR},<span size='10400' font_family='Ubuntu'><b>Colorizer</b> Cava</span>
|
|
|
|
|
|
$(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[@]}"
|
|
|