From 876c236e881304871d00f4dfa549629dd7a9efe0 Mon Sep 17 00:00:00 2001 From: Daniel Napora Date: Tue, 9 May 2023 14:14:23 +0200 Subject: [PATCH] Cava module --- bin/cavactl | 90 ++++++++++++ bin/colorizer | 8 ++ bin/colorizer-cava | 221 +++++++++++++++++++++++++++++ bin/colorizer-conky | 41 +++--- bin/colorizer-menus | 77 ++++++++-- bin/conkyctl | 148 +++++++++++-------- bin/jgctl | 93 ++++++++++-- bin/mbgrad | 5 + bin/obtctl | 6 +- bin/w2theme | 16 +++ share/mabox-colorizer/help/en.html | 5 +- share/mabox-colorizer/help/pl.html | 6 +- 12 files changed, 610 insertions(+), 106 deletions(-) create mode 100755 bin/cavactl create mode 100755 bin/colorizer-cava diff --git a/bin/cavactl b/bin/cavactl new file mode 100755 index 0000000..6519497 --- /dev/null +++ b/bin/cavactl @@ -0,0 +1,90 @@ +#!/bin/bash + +# cavactl - cava script for Mabox +CFGFILE=~/.config/cava/config + +reload_config() { +pkill -USR1 cava +} + +reload_colors() { +pkill -USR2 cava > /dev/null 2>&1 +} +mode() { + case "$1" in + solid) sd ".*gradient .*" "gradient = 0" ${CFGFILE};; + gradient) sd ".*gradient .*" "gradient = 1" ${CFGFILE};; + esac + reload_colors +} + +foregroundcolor(){ + sd ".*foreground .*" "foreground = '${1}'" ${CFGFILE} +} + +foreground() { +sd ".*foreground .*" "foreground = '${1}'" ${CFGFILE} +sd ".*gradient .*" "gradient = 0" ${CFGFILE} +reload_colors +} +gradientcolors() { + n=1 +for i in $(pastel gradient -n 8 ${1} ${2}|pastel format hex) + do + sd ".*gradient_color_${n}.*" "gradient_color_${n} = '${i}'" ${CFGFILE} + ((n++)) + done +} +gradient() { + n=1 +for i in $(pastel gradient -n 8 ${1} ${2}|pastel format hex) + do + sd ".*gradient_color_${n}.*" "gradient_color_${n} = '${i}'" ${CFGFILE} + ((n++)) + done + +sd ".*gradient .*" "gradient = 1" ${CFGFILE} +sd ".*gradient_count .*" "gradient_count = 8" ${CFGFILE} +reload_colors +} +grad_from() { + read GR_TO <<< "$(grep '.*gradient_color_8 ' ${CFGFILE} | cut -d"'" -f2)" + gradient "$1" "${GR_TO}" +} +grad_to() { + read GR_FROM <<< "$(grep '.*gradient_color_1 ' ${CFGFILE} | cut -d"'" -f2)" + gradient "${GR_FROM}" "$1" +} + +bar_width () { +sd ".*bar_width .*" "bar_width = ${1}" ${CFGFILE} +reload_config +} + + +bar_spacing() { +sd ".*bar_spacing .*" "bar_spacing = ${1}" ${CFGFILE} +reload_config +} + + + + + + + +case "$1" in + mode) mode "$2";; + foregroundcolor) foregroundcolor "$2";; + foreground) foreground "$2";; + gradientcolors) gradientcolors "$2" "$3";; + gradient) gradient "$2" "$3";; + grad_from) grad_from "$2";; + grad_to) grad_to "$2";; + reload) reload_config;; + reload_colors)reload_colors;; + bar_width)bar_width "$2";; + bar_spacing)bar_spacing "$2";; + + *):;; +esac diff --git a/bin/colorizer b/bin/colorizer index dc9f9a0..c61d8ce 100755 --- a/bin/colorizer +++ b/bin/colorizer @@ -64,6 +64,7 @@ case "$LANG" in MODULES="Moduły" OBTHEME="Motyw Openbox" MENUPANELS="Menu i Panele" + CAVA="Cava - wizualizacja dźwięku" TERMINALTHEME="Motyw terminala" WALLCOLORS="Kolory z tapety" ACCENTINFO="ustaw kolor akcentu..." @@ -158,6 +159,7 @@ case "$LANG" in MODULES="Modules" OBTHEME="Openbox Theme" MENUPANELS="Menus/Panels" + CAVA="Cava - Audio Visualizer" TERMINALTHEME="Terminal color scheme" WALLCOLORS="Wallpaper Colors" ACCENTINFO="click to set accent color" @@ -306,6 +308,12 @@ if pgrep -f pyradio >/dev/null ;then out+=("PyRadio,^pipe(colorizer-pyradio)") fi +if pgrep -f cava >/dev/null ;then + out+=("^sep()") + out+=("$CAVA,^pipe(colorizer-cava)") +fi + + out+=("^sep($WALLCOLORS)") out+=("北 $REGENERATE,^checkout(regen)") out2+=("^tag(regen)") diff --git a/bin/colorizer-cava b/bin/colorizer-cava new file mode 100755 index 0000000..b0d9bc7 --- /dev/null +++ b/bin/colorizer-cava @@ -0,0 +1,221 @@ +#!/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 . + + + +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*) + 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" + MODGRAD_FROM="Gradient kolor 1" + MODGRAD_TO="Gradient kolor 2" + EDITCONF="Edytuj plik konfiguracyjny" + RELOAD="Przeładuj konfigurację" + RELOAD_COLORS="Przeładuj kolory" + ;; + *) + 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" + 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)" + +FGC=$(pastel textcolor ${FG}|pastel format hex) +} + getvalues + out+=("^sep($COLORIZE_CAVA)") + + out+=(" ${FG} $COLOR,^pipe(mbclr '$FG' cavactl foreground Cava_Bar_Color '$me')") + out+=("^sep($GRADIENT)") + out+=(" Gradient,^pipe(mbgrad cava)") + out+=(" $REVERSE_GRADIENT,cavactl gradient '${GR_TO}' '${GR_FROM}';$me") + out+=("^sep()") + out+=(" $MODGRAD_FROM,^pipe(mbclr '$GR_FROM' cavactl grad_from Cava_Grad_From_Color '$me')") + out+=(" $MODGRAD_TO,^pipe(mbclr '$GR_TO' cavactl grad_to Cava_Grad_To_Color '$me')") + out+=("^sep($COLOR_MODE)") + [[ "$GR" == "0" ]] && out+=(" $SOLID_COLOR,cavactl mode solid;$me" "󰝦 $GRADIENT,cavactl mode gradient;$me") || out+=("󰝦 $SOLID_COLOR,cavactl mode solid;$me" " $GRADIENT,cavactl mode gradient;$me") + + + out+=("^sep($BARS)") + out+=("$BAR_WIDTH [ $BW ],^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 [ $BS ],^checkout(barspacing)") + out2+=("^tag(barspacing)") + out2+=("^sep($BAR_SPACING)") + for i in 0 1 2 3 4 + 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($GENERATEFROMWP)") + out+=(" $LIGHTBG,w2theme cava light;$me") + out+=(" $DARKBG,w2theme cava dark;$me") + +### 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 < ${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},Colorizer Cava + + +$(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[@]}" + diff --git a/bin/colorizer-conky b/bin/colorizer-conky index 4ba0570..1278c09 100755 --- a/bin/colorizer-conky +++ b/bin/colorizer-conky @@ -224,7 +224,7 @@ if pgrep -af "conky.*mbcolor" >/dev/null; then out+=("^sep()") out+=("$STARTALL (${#notstarted[@]}),conkyctl startall;$me") fi - else # too many conkies - not started go to submenu + else # too many conkies not started -> show them in submenu out+=("$CLICKTOSTART (${#notstarted[@]}),^checkout(nstarted)") out2+=("^tag(nstarted)") for c in ${notstarted[@]};do @@ -256,6 +256,27 @@ if pgrep -af "conky.*mbcolor" >/dev/null; then #GLOBAL START out+=("^sep($GLOBALSETTINGS)") + + if [ "$WINTRANS" == false ];then + out+=(" AbCd $BACKGROUND,^pipe(mbclr '$WINCLR' conkyctl win_bgcolor_all '${BACKGROUND}' '$me')") + else + out+=(" transparent $BACKGROUND,^pipe(mbclr '$WINCLR' conkyctl win_bgcolor_all '${BACKGROUND}' '$me')") + fi + out+=("$TRANSPARENT [ $WINTRANS ],^checkout(trans)") + out+=("^sep()") + + + out+=(" AbCd $DEFCOLOR,^pipe(mbclr '$CLR' conkyctl default_color_all '${DEFCOLOR}' '$me')") + out+=(" AbCd $COLOR_0,^pipe(mbclr '$CLR0' conkyctl color0_all '${COLOR_0}' '$me')") + out+=(" AbCd $COLOR_1,^pipe(mbclr '$CLR1' conkyctl color1_all '${COLOR_1}' '$me')") + out+=(" AbCd $COLOR_2,^pipe(mbclr '$CLR2' conkyctl color2_all '${COLOR_2}' '$me')") + #out+=("^sep()") + out2+=("^tag(trans)") + out2+=("^sep($TRANSPARENT)") + out2+=("$YES,conkyctl transparent_all true;$me") + out2+=("$NO,conkyctl transparent_all false;$me") + out+=("^sep()") + out+=(" $REGENERATE,^checkout(regenconky)") out2+=("^tag(regenconky)") out2+=("^sep($REGENERATE)") @@ -272,25 +293,9 @@ if pgrep -af "conky.*mbcolor" >/dev/null; then done out2+=("^sep()") out2+=(" $OPENTHEMEDIR,xdg-open ${COLORIZERDIR}/conky/themes/") + out+=("^sep()") - if [ "$WINTRANS" == false ];then - out+=(" AbCd $BACKGROUND,^pipe(mbclr '$WINCLR' conkyctl win_bgcolor_all '${BACKGROUND}' '$me')") - else - out+=(" transparent $BACKGROUND,^pipe(mbclr '$WINCLR' conkyctl win_bgcolor_all '${BACKGROUND}' '$me')") - fi - out+=("$TRANSPARENT [ $WINTRANS ],^checkout(trans)") - out+=("^sep()") - out+=(" AbCd $DEFCOLOR,^pipe(mbclr '$CLR' conkyctl default_color_all '${DEFCOLOR}' '$me')") - out+=(" AbCd $COLOR_0,^pipe(mbclr '$CLR0' conkyctl color0_all '${COLOR_0}' '$me')") - out+=(" AbCd $COLOR_1,^pipe(mbclr '$CLR1' conkyctl color1_all '${COLOR_1}' '$me')") - out+=(" AbCd $COLOR_2,^pipe(mbclr '$CLR2' conkyctl color2_all '${COLOR_2}' '$me')") - #out+=("^sep()") - out2+=("^tag(trans)") - out2+=("^sep($TRANSPARENT)") - out2+=("$YES,conkyctl transparent_all true;$me") - out2+=("$NO,conkyctl transparent_all false;$me") - out+=("^sep()") out+=("$FONTS [ $FONT $FONTSIZE ],^checkout(font)") out2+=("^tag(font)") out2+=("^sep($FONTS)") diff --git a/bin/colorizer-menus b/bin/colorizer-menus index b03088c..a973fc3 100755 --- a/bin/colorizer-menus +++ b/bin/colorizer-menus @@ -107,7 +107,7 @@ case "$LANG" in BOTTOM_LEFT="bottom_left" BOTTOM_RIGHT="bottom_right" PRE_GRADIENTS="Predefined gradients" - GRADIENT_REVERSE="Reverse Gradient" + GRADIENT_REVERSE="Reverse gradient colors" ITEM="item" COLOR_NORM_FG="Text Color" COLOR_SEL_BG="Selected Item Background" @@ -161,6 +161,25 @@ getvalues out+=("^sep($MENU_THEME: ${jgmenu_theme})") +out+=("Quick Menu tweaks,^checkout(tweaks)") +out2+=("^tag(tweaks)") +out2+=("^sep(Overall style)") +out2+=("Solid Color,jgctl tweak solid;$me") +out2+=("Gradient,jgctl tweak gradient;$me") +out2+=("^sep(Opacity)") +out2+=("100% Opaque,jgctl tweak opacity 100;$me") +out2+=("80%,jgctl tweak opacity 80;$me") +out2+=("60%,jgctl tweak opacity 60;$me") +out2+=("40%,jgctl tweak opacity 40;$me") +out2+=("30%,jgctl tweak opacity 30;$me") +out2+=("20%,jgctl tweak opacity 20;$me") +out2+=("10%,jgctl tweak opacity 10;$me") +out2+=("0% Fully transparent,jgctl tweak opacity 0;$me") +out2+=("^sep(MENU_PADDING)") +out2+=("wide,jgctl tweak padding wide;$me") +out2+=("normal,jgctl tweak padding normal;$me") +out2+=("tight,jgctl tweak padding tight;$me") + out+=("^sep($GENERATEFROMWP)") out+=("$LIGHTBG,w2theme menu light;$me") out+=("$DARKBG,w2theme menu dark;$me") @@ -169,32 +188,65 @@ out+=("$(printf '%3s' "$MBGA") $COLOR_MENU_BG_TO,^pipe(mbclr '$MBGT' jgctl color_menu_bg_to '${COLOR_MENU_BG_TO}' '$me')") out+=("$(printf '%3s' "$MBORDERA") $COLOR_MENU_BORDER,^pipe(mbclr '$MBORDER' jgctl color_menu_border '${COLOR_MENU_BORDER}' '$me')") out+=("^sep()") -out+=("$GRADIENT_POS [ $GRADIENT ],^checkout(gradientpos)") + +case "$GRADIENT" in + none)icon="";; + top)icon="";; + right)icon="";; + bottom)icon="";; + left)icon="";; + top_left)icon="";; + top_right)icon="";; + bottom_left)icon="";; + bottom_right)icon="";; +esac + +out+=("$icon $GRADIENT_POS [ $GRADIENT ],^checkout(gradientpos)") +#for i in $(pastel gradient "$MBGT" "$MBG" -n 13|pastel format hex) +#do +#gradrev+=(" ") +#done + +#out+=("$(printf '%s' "${gradrev[@]}") 凌 $GRADIENT_REVERSE,jgctl gradient '${MBGT}' '${MBG}';$me") +out+=(" 凌 $GRADIENT_REVERSE,jgctl gradient '${MBGT}' '${MBG}';$me") + +#for i in $(pastel gradient "$MBG" "$MBGT" -n 13|pastel format hex) +#do +#grad+=(" ") +#done +#out+=("$(printf '%s' "${grad[@]}") $PRE_GRADIENTS,^pipe(mbgrad menu)") out+=(" $PRE_GRADIENTS,^pipe(mbgrad menu)") -out+=("凌 $GRADIENT_REVERSE,jgctl gradient '${MBGT}' '${MBG}';$me") + out+=("^sep($ITEM)") out+=("$(printf '%3s' "$NFGA") AbCd $COLOR_NORM_FG,^pipe(mbclr '$NFG' jgctl color_norm_fg '${COLOR_NORM_FG}' '$me')") -out+=("$ITEM_BORDER [ $IBORDER ],^checkout(itemborder)") -out+=("$ITEM_RADIUS [ $IRADIUS ],^checkout(itemradius)") + out+=("$(printf '%3s' "$SBGA") $COLOR_SEL_BG,^pipe(mbclr '$SBG' jgctl color_sel_bg '${COLOR_SEL_BG}' '$me')") out+=("$(printf '%3s' "$SFGA") AbCd $COLOR_SEL_FG,^pipe(mbclr '$SFG' jgctl color_sel_fg '${COLOR_SEL_FG}' '$me')") out+=("$(printf '%3s' "$SBORDERA") $COLOR_SEL_BORDER,^pipe(mbclr '$SBORDER' jgctl color_sel_border '${COLOR_SEL_BORDER}' '$me')") out+=("^sep()") -[[ ! -z "$NORMBG" ]] && out+=("$(printf '%3s' "$NORMBGA") $COLOR_NORM_BG,^pipe(mbclr '$NORMBG' jgctl color_norm_bg '${COLOR_NORM_BG}' '$me')") - +[[ ! -z "$NORMBG" ]] && out+=("$(printf '%3s' "$NORMBGA") $COLOR_NORM_BG,^pipe(mbclr '$NORMBG' jgctl color_norm_bg '${COLOR_NORM_BG}' '$me')" "^sep()") +out+=("$ITEM_BORDER [ $IBORDER ],^checkout(itemborder)") +out+=("$ITEM_RADIUS [ $IRADIUS ],^checkout(itemradius)") out+=("^sep($SEPARATOR_TITLE)") out+=("$(printf '%3s' "$TBGA") $COLOR_TITLE_BG,^pipe(mbclr '$TBG' jgctl color_title_bg '${COLOR_TITLE_BG}' '$me')") out+=("$(printf '%3s' "$TFGA") AbCd $COLOR_TITLE_FG,^pipe(mbclr '$TFG' jgctl color_title_fg '${COLOR_TITLE_FG}' '$me')") out+=("$(printf '%3s' "$TBORDERA") $COLOR_TITLE_BORDER,^pipe(mbclr '$TBORDER' jgctl color_title_border '${COLOR_TITLE_BORDER}' '$me')") out+=("^sep()") -out+=("$SEP_HALIGN [ $SEPHALIGN ],^checkout(sephalign)") + +case "$SEPHALIGN" in + left) icon="";; + center) icon="";; + right) icon="";; +esac + +out+=("$icon $SEP_HALIGN [ $SEPHALIGN ],^checkout(sephalign)") out+=("^sep()") out+=("$(printf '%3s' "$SEPFGA") ------ ${COLOR_SEP_FG},^pipe(mbclr '$SEPFG' jgctl color_sep_fg '${COLOR_SEP_FG}' '$me')") out2+=("^tag(gradientpos)") out2+=("^sep($GRADIENT_POS $GRADIENT)") -out2+=("$NONE,jgctl menu_gradient_pos none;$me") +out2+=(" $NONE,jgctl menu_gradient_pos none;$me") out2+=("^sep()") out2+=(" $TOP,jgctl menu_gradient_pos top;$me") out2+=(" $RIGHT,jgctl menu_gradient_pos right;$me") @@ -293,8 +345,11 @@ JGWIDTH=$((jgtools_padding + 278 + jgtools_padding)) cat < ${MENU_ITEMS} @icon,,$((jgtools_padding + 4)),$((jgtools_padding + 4)),270,150,4,left,top,,,${THUMB} -@rect,,$((jgtools_padding + 4)),$((jgtools_padding + 120)),270,34,0,left,top,#222222 20,#222222 70, -@text,,$((jgtools_padding + 158)),$((jgtools_padding + 124)),120,30,0,left,top,#FFFFFF ,${WINCLR},Colorizer Menus + +@rect,,$((jgtools_padding + 4)),$((jgtools_padding + 120)),270,30,0,left,top,#222222 20,#222222 70, +@text,,$((jgtools_padding + 158)),$((jgtools_padding + 120)),120,30,0,left,top,#FFFFFF ,${WINCLR},Colorizer Menus +@rect,,$((jgtools_padding + 14)),$((jgtools_padding + 22)),35,80,2,left,top,${MBORDER} ${MBORDERA},${MBG} ${MBGA}, +@rect,,$((jgtools_padding + 50)),$((jgtools_padding + 72)),35,60,2,left,top,${MBORDER} ${MBORDERA},${MBG} ${MBGA}, $(printf '%s\n' "${out[@]}") $(printf '%s\n' "${out2[@]}") EOF diff --git a/bin/conkyctl b/bin/conkyctl index 6f8c84f..946c470 100755 --- a/bin/conkyctl +++ b/bin/conkyctl @@ -1,7 +1,7 @@ #!/bin/bash # # conkyctl - script to handle various Conky operations in Mabox -CONKYDIR="$HOME/.config/conky" +CONKYDIR="$HOME"/.config/conky BASECONKY="$CONKYDIR/sysinfo_mbcolor.conkyrc" SESSIONFILE="$CONKYDIR/conky-sessionfile" COLORIZERDIR="$HOME/.config/colorizer" @@ -394,7 +394,7 @@ languages () { SHADOW="Cień" DRAW="Rysuj" BORDERS="Obramowanie" - EDIT="Edytuj plik" + EDIT="Edytuj plik Conky" RELOAD="Przeładuj" KILL="Zabij" LOGOSIZE="Rozmiar logo" @@ -454,7 +454,7 @@ languages () { SHADOW="Shadow" DRAW="Draw" BORDERS="Borders" - EDIT="Edit file" + EDIT="Edit Conky file" RELOAD="Reload" KILL="Kill" LOGOSIZE="Logo size" @@ -514,7 +514,7 @@ languages () { SHADOW="Shadow" DRAW="Draw" BORDERS="Borders" - EDIT="Edit file" + EDIT="Edit Conky file" RELOAD="Reload" KILL="Kill" LOGOSIZE="Logo size" @@ -598,18 +598,18 @@ if [[ "$OLD_SYNTAX" = "true" ]];then #out+=("^sep($POSITION)") out2+=("^tag(position)") out2+=("^sep($POSITION)") - out2+=(" $MARKNEWPOS,conkyctl setpos ${1};$me") + out2+=(" $MARKNEWPOS,conkyctl setpos ${1};$me") #out2+=("^sep()") out2+=("^sep($ALIGNMENT)") - out2+=(" $TOPLEFT,conkyctl pos top_left ${1};$me") - out2+=(" $TOP,conkyctl pos top_middle ${1};$me") - out2+=(" $TOPRIGHT,conkyctl pos top_right ${1};$me") - out2+=(" $LEFT,conkyctl pos middle_left ${1};$me") + out2+=(" $TOPLEFT,conkyctl pos top_left ${1};$me") + out2+=(" $TOP,conkyctl pos top_middle ${1};$me") + out2+=(" $TOPRIGHT,conkyctl pos top_right ${1};$me") + out2+=(" $LEFT,conkyctl pos middle_left ${1};$me") out2+=("$CENTER,conkyctl pos middle_middle ${1};$me") - out2+=(" $RIGHT,conkyctl pos middle_right ${1};$me") - out2+=(" $BOTTOMLEFT,conkyctl pos bottom_left ${1};$me") - out2+=(" $BOTTOM,conkyctl pos bottom_middle ${1};$me") - out2+=(" $BOTTOMRIGHT,conkyctl pos bottom_right ${1};$me") + out2+=(" $RIGHT,conkyctl pos middle_right ${1};$me") + out2+=(" $BOTTOMLEFT,conkyctl pos bottom_left ${1};$me") + out2+=(" $BOTTOM,conkyctl pos bottom_middle ${1};$me") + out2+=(" $BOTTOMRIGHT,conkyctl pos bottom_right ${1};$me") #out2+=("$ALIGNMENT [ $POS ],^checkout(posi)") @@ -696,43 +696,7 @@ if [[ "$OLD_SYNTAX" = "true" ]];then fi out+=("^sep($COLORS)") - if [ "$WINTRANS" == false ];then - - out+=(" $COLORSCHEME,^checkout(regensingle)") - out2+=("^tag(regensingle)") - out2+=("^sep($COLORSCHEME)") - out2+=("$RESETCOLORS,conkyctl resetcolorsone ${1}") - out2+=("^sep($GENFROMWP)") - out2+=("$LIGHTBG,w2theme conkyone light ${1}") - out2+=("$DARKBG,w2theme conkyone dark ${1}") - out2+=("^sep($APPLY_THEME)") - - out3+=("^tag(applytoall)") - out3+=("^sep($APPLY_TO_ALL)") - for i in "${COLORIZERDIR}"/conky/themes/*.colors - do - source "${i}" - themefilename=${i##*/} - themename=${themefilename%%.colors} - ltitle=${themename//-/ } - arr=( $ltitle ) - schemetitle=${arr[@]^} - out2+=(" $schemetitle,conkyctl settheme $themefilename $1") - out3+=(" $schemetitle,conkyctl settheme_all $themefilename") - done - out2+=("^sep()") - out2+=(" $OPENTHEMEDIR,xdg-open ${COLORIZERDIR}/conky/themes/") - out2+=("^sep()") - out2+=("$APPLY_TO_ALL,^checkout(applytoall)") - if [[ "$1" =~ "sysinfo_" ]]; then - out2+=("^sep($NEWTHEME)") - out2+=("$SAVENEWTHEME,conkyctl newcolorscheme ${1}") - fi - - - out+=("^sep()") - - fi + out+=("$TRANSPARENT [ $WINTRANS ],^checkout(transsingle)") if [[ "$WINCLR" != "#" ]];then @@ -759,6 +723,41 @@ if [[ "$OLD_SYNTAX" = "true" ]];then out2+=("$YES,conkyctl transparent true ${1};$me") out2+=("$NO,conkyctl transparent false ${1};$me") + + if [ "$WINTRANS" == false ];then + out+=(" $COLORSCHEME,^checkout(regensingle)") + out2+=("^tag(regensingle)") + out2+=("^sep($COLORSCHEME)") + out2+=("$RESETCOLORS,conkyctl resetcolorsone ${1}") + out2+=("^sep($GENFROMWP)") + out2+=("$LIGHTBG,w2theme conkyone light ${1}") + out2+=("$DARKBG,w2theme conkyone dark ${1}") + out2+=("^sep($APPLY_THEME)") + + out3+=("^tag(applytoall)") + out3+=("^sep($APPLY_TO_ALL)") + for i in "${COLORIZERDIR}"/conky/themes/*.colors + do + source "${i}" + themefilename=${i##*/} + themename=${themefilename%%.colors} + ltitle=${themename//-/ } + arr=( $ltitle ) + schemetitle=${arr[@]^} + out2+=(" $schemetitle,conkyctl settheme $themefilename $1") + out3+=(" $schemetitle,conkyctl settheme_all $themefilename") + done + out2+=("^sep()") + out2+=(" $OPENTHEMEDIR,xdg-open ${COLORIZERDIR}/conky/themes/") + out2+=("^sep()") + out2+=("$APPLY_TO_ALL,^checkout(applytoall)") + if [[ "$1" =~ "sysinfo_" ]]; then + out2+=("^sep($NEWTHEME)") + out2+=("$SAVENEWTHEME,conkyctl newcolorscheme ${1}") + fi + out+=("^sep()") + fi + if [[ "$1" != *"logo_mbcolor"* ]]; then if [[ "$1" != *"quoter_mbcolor"* ]]; then out+=("$FONTS [ $FONT $FONTSIZE ],^checkout(fontsingle)") @@ -871,12 +870,12 @@ contextmenu () { single "${CONKYCFG}" "s" case "$LANG" in - pl*)EDIT_CUSTOMCOMMANDS=" Edytuj menu komend (lewy klik menu)";; - es*)EDIT_CUSTOMCOMMANDS=" Edit cmd menu (left clik menu)";; - *) EDIT_CUSTOMCOMMANDS=" Edit cmd menu (left clik menu)";; + pl*)EDIT_CUSTOMCOMMANDS=" Edytuj menu komend (lewy klik) dla ${name^}";; + es*)EDIT_CUSTOMCOMMANDS=" Edit cmd menu (left clik) for ${name^}";; + *) EDIT_CUSTOMCOMMANDS=" Edit cmd menu (left clik) for ${name^}";; esac out+=("^sep()") - out+=("$EDIT_CUSTOMCOMMANDS,touch ${CONKYDIR}/menuscripts/${name}.csv;sleep 1;xdg-open ${CONKYDIR}/menuscripts/${name}.csv") + out+=("$EDIT_CUSTOMCOMMANDS,conkyctl cmdmenu_edit ${name}") out+=("^sep()") out+=(" ⮜⮜⮜ Conky Manager (Colorizer),colorizer-conky -s") @@ -961,11 +960,22 @@ cmdmenu () { if [ -f ${CONKYDIR}/menuscripts/${name}.csv ]; then LINES=$(grep -Ev "^#|^$" ${CONKYDIR}/menuscripts/${name}.csv|wc -l) #notify-send.sh "$LINES" - if [ ${LINES} != 0 ]; then - CUSTOMCOMMANDS=". ${CONKYDIR}/menuscripts/${name}.csv" - else + if [ ${LINES} == 0 ]; then contextmenu fi + if [ ${LINES} == 1 ]; then + # 1 line - execute command (one line menu make no sense) + while IFS=$'\r\n' read -r line + do + cmd=${line#*,} + label=${line%,*} + done <<< $(grep -v '^\s*$\|^#\|^\s*#' ${CONKYDIR}/menuscripts/${name}.csv) + #notify-send.sh "${label}" "${cmd[@]}" + ${cmd[@]} + else + # more than 1 lines - show menu + CUSTOMCOMMANDS=". ${CONKYDIR}/menuscripts/${name}.csv" + fi else contextmenu fi @@ -996,7 +1006,7 @@ cmdmenu () { jgtools_padding=4 MENU_PADDING_TOP=${jgtools_padding:-0} JGWIDTH=270 - TABS="90" + TABS="300" jgmenu_icon_size=0 mkconfigfile @@ -1035,6 +1045,7 @@ cmdmenu () { #echo "menu_margin_x=3" >> ${CONFIG_FILE} #echo "menu_margin_y=3" >> ${CONFIG_FILE} #notify-send.sh "CFG" "$(cat $CONFIG_FILE)" + echo "tabs = 170" >>${CONFIG_FILE} case "$LANG" in pl*) CUSTOM_COMMANDS_SEP="Własne polecenia" @@ -1055,6 +1066,26 @@ EOF jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null } +cmdmenu_edit() { + if [[ -f "${CONKYDIR}/menuscripts/${1}.csv" ]];then + geany "${CONKYDIR}/menuscripts/${1}.csv" + else + +cat < "${CONKYDIR}/menuscripts/${1}.csv" +# Add your commands here +# Syntax is simple: Label,command +# examples: + +#The Gimp,gimp +#Firefox,firefox --new-window https://maboxlinux.org +#Btop,terminator -T Btop -e btop + +# If only one command is uncommented it will run, if more commands available menu will be shown +# to see how it works play with uncomenting examples above and clicking Conky +EOF +geany "${CONKYDIR}/menuscripts/${1}.csv" + fi +} netdevice () { CFGFILE="$HOME/.config/conky/Network_mbcolor.conkyrc" @@ -1287,6 +1318,7 @@ case "$1" in restartone) restartone "$2";; contextmenu) contextmenu;; cmdmenu) cmdmenu;; + cmdmenu_edit) cmdmenu_edit "$2";; makemoveableall) makemoveableall;; saveposall) saveposall;; resetcolorsall) resetcolorsall ;; diff --git a/bin/jgctl b/bin/jgctl index 5b1f489..d06307d 100755 --- a/bin/jgctl +++ b/bin/jgctl @@ -73,32 +73,50 @@ gradient () { read MBGT MBGTA<<< "$(grep 'color_menu_bg_to ' ${THEMERC} | cut -d'=' -f2)" sd "color_menu_bg .*$" "color_menu_bg = $1 $MBGA" ${THEMERC} sd "color_menu_bg_to.*$" "color_menu_bg_to = $2 $MBGTA" ${THEMERC} +# Item ITEM_FG=$(pastel textcolor ${2}|pastel format hex) - read NFG NFGA<<< "$(grep 'color_norm_fg' ${THEMERC} | cut -d'=' -f2)" - sd "color_norm_fg.*$" "color_norm_fg = $ITEM_FG $NFGA" ${THEMERC} -# Title - read TBG TBGA<<< "$(grep 'color_title_bg' ${THEMERC} | cut -d'=' -f2)" - sd "color_title_bg.*$" "color_title_bg = $1 $TBGA" ${THEMERC} - # calculate readable FG color - TITLE_FG=$(pastel textcolor ${1}|pastel format hex) - read TFG TFGA<<< "$(grep 'color_title_fg' ${THEMERC} | cut -d'=' -f2)" - if [[ "${TITLE_FG}" == *"ffffff"* ]];then - TITLE_FGCOLOR=$(pastel mix -f 0.6 '#ffffff' "${2}"|pastel format hex) + if [[ "${ITEM_FG}" == *"ffffff"* ]];then + ITEM_FGCOLOR="#c0c0c0" else - TITLE_FGCOLOR=$(pastel mix -f 0.6 '#000000' "${2}"|pastel format hex) + ITEM_FGCOLOR="#222222" + fi + + + read NFG NFGA<<< "$(grep 'color_norm_fg' ${THEMERC} | cut -d'=' -f2)" + sd "color_norm_fg.*$" "color_norm_fg = $ITEM_FGCOLOR $NFGA" ${THEMERC} + read NBG NBGA<<< "$(grep 'color_norm_bg' ${THEMERC} | cut -d'=' -f2)" + sd "color_norm_bg.*$" "color_norm_bg = $2 $NBGA" ${THEMERC} +# Title (Separator with text) + read TBG TBGA<<< "$(grep 'color_title_bg' ${THEMERC} | cut -d'=' -f2)" + sd "color_title_bg.*$" "color_title_bg = $2 $TBGA" ${THEMERC} + # calculate readable FG color + TITLE_FG=$(pastel textcolor ${2}|pastel format hex) + read TFG TFGA<<< "$(grep 'color_title_fg' ${THEMERC} | cut -d'=' -f2)" + + ###TITLE_FGCOLOR=$(pastel complement ${2}|pastel format hex) + if [[ "${TITLE_FG}" == *"ffffff"* ]];then + TITLE_FGCOLOR=$(pastel mix -f 0.7 '#ffffff' "${2}"|pastel format hex) + else + TITLE_FGCOLOR=$(pastel mix -f 0.7 '#000000' "${2}"|pastel format hex) fi sd "color_title_fg.*$" "color_title_fg = ${TITLE_FGCOLOR} $TFGA" ${THEMERC} + ###sd "color_title_fg.*$" "color_title_fg = ${1} $TFGA" ${THEMERC} read TBORDER TBORDERA<<< "$(grep 'color_title_border' ${THEMERC} | cut -d'=' -f2)" TITLE_BORDER=$(pastel darken 0.05 ${1}|pastel format hex) sd "color_title_border.*$" "color_title_border = $TITLE_BORDER $TBORDERA" ${THEMERC} -# Active item +# Selected (Active) item read SBG SBGA<<< "$(grep 'color_sel_bg' ${THEMERC} | cut -d'=' -f2)" alpha=${SBGA:-100} sd "color_sel_bg.*$" "color_sel_bg = $2 $alpha" ${THEMERC} ACTIVE_FG=$(pastel textcolor ${2}|pastel format hex) read SFG SFGA<<< "$(grep 'color_sel_fg' ${THEMERC} | cut -d'=' -f2)" sd "color_sel_fg.*$" "color_sel_fg = $ACTIVE_FG $SFGA" ${THEMERC} - # Sep + + read SBORDER SBORDERA<<< "$(grep 'color_sel_border' ${THEMERC} | cut -d'=' -f2)" + alpha=${SBORDERA:-100} + sd "color_sel_border.*$" "color_sel_border = $1 $alpha" ${THEMERC} + +# Separator line read SFG SFGA<<< "$(grep 'color_sep_fg' ${THEMERC} | cut -d'=' -f2)" SEP_FG=$(pastel mix -f 0.5 "${1}" "${2}"|pastel format hex) sd "color_sep_fg.*$" "color_sep_fg = $SEP_FG $SFGA" ${THEMERC} @@ -215,6 +233,53 @@ color_sel_border () { sd "color_sel_border.*$" "color_sel_border = $SBORDER $1" ${THEMERC} ;; esac + read IBOR<<< "$(grep 'item_border' ${THEMERC} | cut -d'=' -f2)" + [[ ${IBOR} == "0" ]] && item_border 1 +} +tweak () { + case "$1" in + solid) + menu_gradient_pos none + tweak opacity 100 + opacity color_norm_bg 0 + opacity color_sep_fg 30 + item_radius 0 + item_border 0 + ;; + gradient) + menu_gradient_pos right + opacity color_norm_bg 10 + opacity color_sep_fg 0 + item_radius 3 + item_border 0 + ;; + opacity) + opacity color_menu_bg "$2" + opacity color_menu_bg_to "$2" + ;; + padding) + case "$2" in + tight) + mb-setvar jgtools_padding=0 + ;; + normal) + mb-setvar jgtools_padding=8 + ;; + wide) + mb-setvar jgtools_padding=20 + ;; + esac + ;; + *):;; + esac +} +opacity () { + # jgctl opacity element value + read FUNC B COLOR OPACITY REST<<< "$(grep ${1} ${THEMERC})" + #echo "$FUNC $B $COLOR $OPACITY $REST" + + sd "$1.*= $COLOR.*$" "$FUNC = $COLOR $2 $REST" ${THEMERC} + } case "$1" in theme) theme "$2";; @@ -237,5 +302,7 @@ case "$1" in color_sel_bg) color_sel_bg "$2";; color_sel_fg) color_sel_fg "$2";; color_sel_border) color_sel_border "$2";; + tweak) tweak "$2" "$3";; + opacity) opacity "$2" "$3";; *) : ;; esac diff --git a/bin/mbgrad b/bin/mbgrad index 55df425..29fbf0a 100755 --- a/bin/mbgrad +++ b/bin/mbgrad @@ -16,6 +16,11 @@ case "$1" in COMMAND="jgctl gradient" me="colorizer-menus -s" ;; + cava) + CACHEFILE="$HOME"/.config/colorizer/grad_cava.csv + COMMAND="cavactl gradient" + me="colorizer-cava -s" + ;; *) CACHEFILE="$HOME"/.config/colorizer/grad_root.csv COMMAND="w2theme gradient" diff --git a/bin/obtctl b/bin/obtctl index 6acb9ca..e282348 100755 --- a/bin/obtctl +++ b/bin/obtctl @@ -419,7 +419,7 @@ fontslanttoggle (){ } randomizer () { - # TODO: - maybe put all options to cnf file and let users cistomize oprions??? + # TODO: - maybe put all options to cnf file and let users cistomize options??? ### ensure we use MBColors at the moment theme MBcolors @@ -482,8 +482,8 @@ randomizer () { textjustify "${ALIGN}" ### FONT FAMILY - FAMILIES=(Ubuntu Sans Serif "Roboto Condensed" "GE Inspira") - rand=$((RANDOM%5)) + FAMILIES=(Ubuntu Sans "Roboto Condensed" "GE Inspira") + rand=$((RANDOM%4)) FAMILY="${FAMILIES[$rand]}" fontfamily "${FAMILY}" diff --git a/bin/w2theme b/bin/w2theme index 59cc417..500b79c 100755 --- a/bin/w2theme +++ b/bin/w2theme @@ -153,6 +153,21 @@ pyradio_theme() { ;; esac } +cava () { + case "$1" in + light) #light bottom + cavactl gradientcolors "${w[-3]}" "${w[3]}" + cavactl foregroundcolor "${w[-3]}" + cavactl reload_colors + ;; + *) #dark bottom + cavactl gradientcolors "${w[3]}" "${w[-3]}" + cavactl foregroundcolor "${w[3]}" + cavactl reload_colors + ;; + esac +} + accent () { #obtctl clractivebg ${1} #colorTo=$(pastel darken 0.2 "${1}"|pastel format hex) @@ -389,6 +404,7 @@ case "$1" in conky) conky_colors "$2";; conkyone) conky_colorsone "$2" "$3";; pyradio) pyradio_theme "$2";; + cava) cava "$2";; accent) accent "$2";; gradient) gradient "$2" "$3";; colorize) colorize;; diff --git a/share/mabox-colorizer/help/en.html b/share/mabox-colorizer/help/en.html index 5c3b7ff..9279337 100644 --- a/share/mabox-colorizer/help/en.html +++ b/share/mabox-colorizer/help/en.html @@ -49,11 +49,13 @@ kbd { padding: 2px 4px; white-space: nowrap; } +nav button.w3-bar-item {padding:4px 12px !important;}
+ +
Choose wallpaperChoose wallpaper from image context menu Colorizer RootmenuColorizer Menu (advanced) Openbox moduleOpenbox Window Decoration module diff --git a/share/mabox-colorizer/help/pl.html b/share/mabox-colorizer/help/pl.html index 8989894..ccf6663 100644 --- a/share/mabox-colorizer/help/pl.html +++ b/share/mabox-colorizer/help/pl.html @@ -49,13 +49,14 @@ kbd { padding: 2px 4px; white-space: nowrap; } - +nav button.w3-bar-item {padding:4px 12px !important;}