From b17d8f80946b6efe52ce6a508c517bd36ec18636 Mon Sep 17 00:00:00 2001 From: Daniel Napora Date: Wed, 6 Jul 2022 08:41:00 +0200 Subject: [PATCH] themes generators from wallpaper colors --- bin/colorizer | 23 +++++++++++ bin/colorizer-conky | 16 ++++++++ bin/colorizer-menus | 16 ++++++++ bin/colorizer-pyradio | 86 ++++++++++++++++++++++++++++++++++++++++ bin/prtctl | 56 ++++++++++++++++++++++++++ bin/w2theme | 92 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 289 insertions(+) create mode 100755 bin/colorizer-pyradio create mode 100755 bin/prtctl create mode 100755 bin/w2theme diff --git a/bin/colorizer b/bin/colorizer index adf2eb0..e879215 100755 --- a/bin/colorizer +++ b/bin/colorizer @@ -1,10 +1,21 @@ #!/bin/bash +WALLPALDIR="$HOME/.config/colormenu/palettes/wallp" +mkdir -p "$WALLPALDIR" +read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) +WALLPAPER=${WALLPATH##*/} +if [ ! -f "$WALLPALDIR/$WALLPAPER.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/$WALLPAPER.clr" +fi +mapfile -t w < "$WALLPALDIR/$WALLPAPER.clr" + case "$LANG" in pl*) OBTHEME="Motyw Openbox" MENUPANELS="Menu i Panele" TERMINALTHEME="Motyw terminala" + WALLCOLORS="Kolory z tapety" + ACCENTINFO="ustaw kolor akcentu" OTHERTOOLS="Inne narzędzia" WALLPAPER="Tapety" HELP="Pomoc" @@ -13,6 +24,8 @@ case "$LANG" in OBTHEME="Openbox Theme" MENUPANELS="Menus/Panels" TERMINALTHEME="Terminal color scheme" + WALLCOLORS="Wallpaper Colors" + ACCENTINFO="click to set accent color" OTHERTOOLS="Other tools" WALLPAPER="Wallpaper" HELP="About and Help" @@ -26,7 +39,17 @@ out+=("$MENUPANELS,^pipe(colorizer-menus)") out+=("Conky,^pipe(colorizer-conky)") #out+=("Systray HW monitor,^pipe(colorizer-phwmon)") out+=("$TERMINALTHEME,^term(theme.sh -i2;/bin/bash)") +out+=("^sep()") +out+=("PyRadio,^pipe(colorizer-pyradio)") #out+=("GTKTHEME,^pipe(colorizer-gtktheme)") +out+=("^sep($WALLCOLORS)") +out+=("^sep($ACCENTINFO)") +for i in "${w[@]}" +do +out+=("$i ,obtctl clractivebg '${i}';colorizer -s") +done +out+=("^sep()") +out+=("RANDOM_WALLPAPER,nitrogen --random /usr/share/backgrounds --set-scaled --save;colorizer -s") out+=("^sep($OTHERTOOLS)") out+=("Tint2 Menu,^pipe(jgtint2-pipe)") out+=("$WALLPAPER,^pipe(jgwallpaperchanger)") diff --git a/bin/colorizer-conky b/bin/colorizer-conky index 686eff6..6f5b0c2 100755 --- a/bin/colorizer-conky +++ b/bin/colorizer-conky @@ -20,6 +20,19 @@ update_notifications=true EOF fi +case "$LANG" in + pl*) + GENERATEFROMWP="Generuj z kolorów tapety" + LIGHTBG="Jasne tło" + DARKBG="Ciemne tło" + ;; + *) + GENERATEFROMWP="Generate from wallpaper colors" + LIGHTBG="Light Background" + DARKBG="Dark Background" + ;; +esac + getvalues () { read WINTRANS <<< "$(grep own_window_transparent ${BASECONKY} | cut -d'=' -f2 | cut -d"," -f1)" read FONTDEF <<< "$(grep "font .*=.*,$" ${BASECONKY} | cut -d'=' -f2,3 |cut -d"'" -f2)" @@ -52,6 +65,9 @@ if pgrep -af "conky.*mbcolor" >/dev/null; then [[ "$WINTRANS" == false ]] && BG="bgcolor='$WINCLR'" || BG="" out+=("^sep(Colorize Conky)") + out+=("^sep($GENERATEFROMWP)") + out+=("$LIGHTBG,w2theme conky light;$me") + out+=("$DARKBG,w2theme conky dark;$me") out+=("^sep(Global settings (apply to all))") out+=(" AbCd Default color (normal text and border),^pipe(mbclr '$CLR' conkyctl default_color_all DEFAULT_COLOR '$me')") out+=(" AbCd Color 0 (normal text2),^pipe(mbclr '$CLR0' conkyctl color0_all COLOR_0 '$me')") diff --git a/bin/colorizer-menus b/bin/colorizer-menus index 39fb037..edcc879 100755 --- a/bin/colorizer-menus +++ b/bin/colorizer-menus @@ -16,6 +16,18 @@ esac if [ ! -f "${THEMERC}.bak" ]; then cp ${THEMERC} ${THEMERC}.bak fi +case "$LANG" in + pl*) + GENERATEFROMWP="Generuj z kolorów tapety..." + LIGHTBG="Jasne tło" + DARKBG="Ciemne tło" + ;; + *) + GENERATEFROMWP="Generate from wallpaper colors..." + LIGHTBG="Light Background" + DARKBG="Dark Background" + ;; +esac getvalues () { read MBG MBGA<<< "$(grep 'color_menu_bg ' ${THEMERC} | cut -d'=' -f2)" @@ -43,6 +55,10 @@ getvalues out+=("^sep(Menu theme: ${jgmenu_theme})") +out+=("^sep($GENERATEFROMWP)") +out+=("$LIGHTBG,w2theme menu light;$me") +out+=("$DARKBG,w2theme menu dark;$me") +out+=("^sep(menu)") out+=("$(printf '%3s' "$MBGA") COLOR_MENU_BG,^pipe(mbclr '$MBG' jgctl color_menu_bg COLOR_MENU_BG '$me')") out+=("$(printf '%3s' "$MBGTA") 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')") diff --git a/bin/colorizer-pyradio b/bin/colorizer-pyradio new file mode 100755 index 0000000..5351356 --- /dev/null +++ b/bin/colorizer-pyradio @@ -0,0 +1,86 @@ +#!/bin/bash + +me="colorizer-pyradio -s" + +case "$LANG" in + pl*) + GENERATEFROMWP="Generuj z kolorów tapety..." + LIGHTBG="Jasne tło" + DARKBG="Ciemne tło" + ;; + *) + GENERATEFROMWP="Generate from wallpaper colors..." + LIGHTBG="Light Background" + DARKBG="Dark Background" + ;; +esac + +#getvalues () { + +#} + + + out+=("^sep(Colorize PyRadio)") + out+=("^sep($GENERATEFROMWP)") + out+=("$LIGHTBG,w2theme pyradio light;$me") + out+=("$DARKBG,w2theme pyradio dark;$me") + + +### RUN +if [[ "$1" == "-s" ]]; then + . /usr/share/mb-jgtools/pipemenu-standalone.cfg + . $HOME/.config/mabox/mabox.conf + + out+=("^sep()") + out+=(" ⮜ Back to Colorizer,colorizer -s") + + if [[ $panels_heightpos == "top" ]]; then + MENU_VALIGN="top" + MENU_MARGIN_Y=${panels_topmargin:-0} + elif [[ $panels_heightpos == "bottom" ]]; then + MENU_VALIGN="bottom" + MENU_MARGIN_Y=${panels_topmargin:-0} + else + MENU_VALIGN="center" + fi + MENU_HALIGN="left" + jgmenu_icon_size=0 + menu_margin_x=${submenu_spacing:-0} + [ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius + [ -z $jgmenu_use_borders ] && menu_border=0 + JGWIDTH=$((jgtools_padding + 278 + jgtools_padding)) + MENU_PADDING_TOP=$((jgtools_padding + 158)) + + #WALLPAPER + read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) + WALLPAPER=${WALLPATH##*/} + THUMBDIR="$HOME/.config/mabox/wallthumbs" + mkdir -p ${THUMBDIR} + THUMB="${THUMBDIR}/${WALLPAPER}.png" + if [[ ! -f "$THUMB" ]] + then + convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} + fi + + #TEMP POSITION: + MENU_VALIGN="top" + MENU_MARGIN_Y="60" + mkconfigfile + +cat < ${MENU_ITEMS} +@icon,,$((jgtools_padding + 4)),$((jgtools_padding + 4)),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 + 244)),$((jgtools_padding + 6)),29,60,0,left,top,#FFFFFF 30,${WINCLR} 60, +@rect,,$((jgtools_padding + 5)),$((jgtools_padding + 92)),29,60,0,left,top,#FFFFFF 30,${WINCLR} 60, +@rect,,$((jgtools_padding + 36)),$((jgtools_padding + 112)),29,40,0,left,top,#FFFFFF 30,${WINCLR} 60, +$(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[@]}" + + diff --git a/bin/prtctl b/bin/prtctl new file mode 100755 index 0000000..d7044e6 --- /dev/null +++ b/bin/prtctl @@ -0,0 +1,56 @@ +#!/bin/bash + +# prtctl - pyradio theme helper + +# TODO start pyradio if not running + +THEMERC=~/.config/pyradio/themes/mbcolors.pyradio-theme + +stations() { + read S SFG SBG<<< "$(grep '^Stations ' ${THEMERC})" + #notify-send.sh "$S" "$SFG $SBG" + sd "^Stations .*$" "Stations $1 $2" ${THEMERC} +} +active_station(){ + read AS1 AS2 ASFG<<< "$(grep '^Active Station ' ${THEMERC})" + sd "^Active Station .*$" "Active Station $1" ${THEMERC} +} +status_bar() { + read SB1 SB2 SBFG SBBG<<< "$(grep '^Status Bar ' ${THEMERC})" + sd "^Status Bar .*$" "Status Bar $1 $2" ${THEMERC} +} +normal_cursor() { + read NC1 NC2 NCFG NCBG<<< "$(grep '^Normal Cursor ' ${THEMERC})" + sd "^Normal Cursor .*$" "Normal Cursor $1 $2" ${THEMERC} +} +active_cursor() { + read AC1 AC2 ACFG ACBG<<< "$(grep '^Active Cursor ' ${THEMERC})" + sd "^Active Cursor .*$" "Active Cursor $1 $2" ${THEMERC} +} +edit_cursor() { + read EC1 EC2 ECFG ECBG<<< "$(grep '^Edit Cursor ' ${THEMERC})" + sd "^Edit Cursor .*$" "Edit Cursor $1 $2" ${THEMERC} +} +extra_func() { + sd "^Extra Func .*$" "Extra Func $1" ${THEMERC} +} +pyradio_url() { + sd "^PyRadio URL .*$" "PyRadio URL $1" ${THEMERC} +} +messages_border() { + sd "^Messages Border .*$" "Messages Border $1" ${THEMERC} +} +case "$1" in + stations) stations "$2" "$3";; + stations_fg) stations_fg "$2";; + stations_bg) stations_bg "$2";; + active_station) active_station "$2";; + status_bar) status_bar "$2" "$3";; + normal_cursor) normal_cursor "$2" "$3";; + active_cursor) active_cursor "$2" "$3";; + edit_cursor) edit_cursor "$2" "$3";; + extra_func) extra_func "$2";; + pyradio_url) pyradio_url "$2";; + messages_border) messages_border "$2";; + *);; +esac diff --git a/bin/w2theme b/bin/w2theme new file mode 100755 index 0000000..36c2149 --- /dev/null +++ b/bin/w2theme @@ -0,0 +1,92 @@ +#!/bin/bash + +# w2theme - generate themes from wallpaper colors + +WALLPALDIR="$HOME/.config/colormenu/palettes/wallp" +mkdir -p "$WALLPALDIR" +read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) +WALLPAPER=${WALLPATH##*/} +if [ ! -f "$WALLPALDIR/$WALLPAPER.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/$WALLPAPER.clr" +fi +mapfile -t w < "$WALLPALDIR/$WALLPAPER.clr" + +menu_theme () { + case "$1" in + dark) #dark bg + jgctl color_menu_bg "${w[0]}" + jgctl color_norm_fg "${w[-2]}" + jgctl color_title_bg "${w[2]}" + jgctl color_title_fg "${w[-2]}" + jgctl color_title_border "${w[3]}" + jgctl color_sel_bg "${w[4]}" + jgctl color_sel_fg "${w[-1]}" + jgctl color_sel_border "${w[3]}" + jgctl color_sep_fg "${w[3]}" + ;; + *) #light bg + jgctl color_menu_bg "${w[-1]}" + jgctl color_norm_fg "${w[1]}" + jgctl color_title_bg "${w[-3]}" + jgctl color_title_fg "${w[1]}" + jgctl color_title_border "${w[-4]}" + jgctl color_sel_bg "${w[-5]}" + jgctl color_sel_fg "${w[0]}" + jgctl color_sel_border "${w[-4]}" + jgctl color_sep_fg "${w[-5]}" + + ;; + esac +} +conky_colors() { + case "$1" in + dark) #dark bg + conkyctl win_bgcolor_all "${w[0]}" + conkyctl default_color_all "${w[-1]}" + conkyctl color0_all "${w[-3]}" + conkyctl color1_all "${w[-4]}" + conkyctl color2_all "${w[-5]}" + ;; + *) #light bg + conkyctl win_bgcolor_all "${w[-1]}" + conkyctl default_color_all "${w[0]}" + conkyctl color0_all "${w[2]}" + conkyctl color1_all "${w[3]}" + conkyctl color2_all "${w[4]}" + ;; + esac +} +pyradio_theme() { + case "$1" in + dark) #dark bg + prtctl stations "${w[-3]}" "${w[0]}" + prtctl active_station "${w[-1]}" + prtctl status_bar "${w[0]}" "${w[-3]}" + prtctl normal_cursor "${w[1]}" "${w[-4]}" + prtctl active_cursor "${w[2]}" "${w[-3]}" + prtctl edit_cursor "${w[2]}" "${w[-3]}" + prtctl extra_func "${w[6]}" + prtctl pyradio_url "${w[2]}" + prtctl messages_border "${w[2]}" + ;; + *) # light bg + prtctl stations "${w[4]}" "${w[-1]}" + prtctl active_station "${w[0]}" + prtctl status_bar "${w[0]}" "${w[-3]}" + prtctl normal_cursor "${w[4]}" "${w[-3]}" + prtctl active_cursor "${w[2]}" "${w[-3]}" + prtctl edit_cursor "${w[2]}" "${w[-3]}" + prtctl extra_func "${w[6]}" + prtctl pyradio_url "${w[2]}" + prtctl messages_border "${w[4]}" + ;; + esac +} + +case "$1" in + ob) obtheme "$2";; + menu) menu_theme "$2";; + conky) conky_colors "$2";; + pyradio) pyradio_theme "$2";; + *) ;; +esac