themes generators from wallpaper colors

master
Daniel Napora 2022-07-06 08:41:00 +02:00
parent 3a7072c862
commit b17d8f8094
6 changed files with 289 additions and 0 deletions

View File

@ -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="<i>ustaw kolor akcentu</i>"
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="<i>click to set accent color</i>"
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+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,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)")

View File

@ -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(<small><i>Global settings (apply to all)</i></small>)")
out+=("<small><span bgcolor='$CLR'> </span><span ${BG} fgcolor='$CLR'> AbCd </span></small> Default color <small>(normal text and border)</small>,^pipe(mbclr '$CLR' conkyctl default_color_all DEFAULT_COLOR '$me')")
out+=("<small><span bgcolor='$CLR0'> </span><span ${BG} fgcolor='$CLR0'> AbCd </span></small> Color 0 <small>(normal text2)</small>,^pipe(mbclr '$CLR0' conkyctl color0_all COLOR_0 '$me')")

View File

@ -16,6 +16,18 @@ esac
if [ ! -f "${THEMERC}.bak" ]; then
cp ${THEMERC} ${THEMERC}.bak
fi
case "$LANG" in
pl*)
GENERATEFROMWP="<i>Generuj z kolorów tapety...</i>"
LIGHTBG="Jasne tło"
DARKBG="Ciemne tło"
;;
*)
GENERATEFROMWP="<i>Generate from wallpaper colors...</i>"
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: <i>${jgmenu_theme}</i>)")
out+=("^sep($GENERATEFROMWP)")
out+=("$LIGHTBG,w2theme menu light;$me")
out+=("$DARKBG,w2theme menu dark;$me")
out+=("^sep(menu)")
out+=("<tt><small>$(printf '%3s' "$MBGA")</small> <span bgcolor='$MBG' bgalpha='${MBGA/#[0]/1}%'> </span><span bgcolor='$MBG'> </span></tt> COLOR_MENU_BG,^pipe(mbclr '$MBG' jgctl color_menu_bg COLOR_MENU_BG '$me')")
out+=("<tt><small>$(printf '%3s' "$MBGTA")</small> <span bgcolor='$MBGT' bgalpha='${MBGTA/#[0]/1}%'> </span><span bgcolor='$MBGT'> </span></tt> COLOR_MENU_BG_TO,^pipe(mbclr '$MBGT' jgctl color_menu_bg_to COLOR_MENU_BG_TO '$me')")
out+=("<tt><small>$(printf '%3s' "$MBORDERA")</small> <span bgcolor='$MBORDER' bgalpha='${MBORDERA/#[0]/1}%'> </span><span bgcolor='$MBORDER'> </span></tt> COLOR_MENU_BORDER,^pipe(mbclr '$MBORDER' jgctl color_menu_border COLOR_MENU_BORDER '$me')")

View File

@ -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 <<EOF > ${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[@]}"

56
bin/prtctl 100755
View File

@ -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

92
bin/w2theme 100755
View File

@ -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