mabox-colorizer/bin/colorizer

110 lines
3.5 KiB
Plaintext
Raw Normal View History

2022-05-15 03:25:01 +02:00
#!/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"
2022-06-11 12:57:39 +02:00
case "$LANG" in
pl*)
OBTHEME="Motyw Openbox"
MENUPANELS="Menu i Panele"
TERMINALTHEME="Motyw terminala"
WALLCOLORS="Kolory z tapety"
ACCENTINFO="<i>ustaw kolor akcentu</i>"
2022-06-11 12:57:39 +02:00
OTHERTOOLS="Inne narzędzia"
WALLPAPER="Tapety"
HELP="Pomoc"
;;
*)
OBTHEME="Openbox Theme"
MENUPANELS="Menus/Panels"
TERMINALTHEME="Terminal color scheme"
WALLCOLORS="Wallpaper Colors"
ACCENTINFO="<i>click to set accent color</i>"
2022-06-11 12:57:39 +02:00
OTHERTOOLS="Other tools"
WALLPAPER="Wallpaper"
HELP="About and Help"
;;
esac
2022-05-15 03:25:01 +02:00
out+=("^sep(Mabox Colorizer)")
2022-06-11 12:57:39 +02:00
out+=("$OBTHEME,^pipe(colorizer-ob)")
out+=("$MENUPANELS,^pipe(colorizer-menus)")
2022-05-15 03:25:01 +02:00
#out+=("TINT2,^pipe(colorizer-tint2)")
out+=("Conky,^pipe(colorizer-conky)")
2022-05-15 15:56:00 +02:00
#out+=("Systray HW monitor,^pipe(colorizer-phwmon)")
2022-06-11 12:57:39 +02:00
out+=("$TERMINALTHEME,^term(theme.sh -i2;/bin/bash)")
out+=("^sep()")
out+=("PyRadio,^pipe(colorizer-pyradio)")
2022-05-15 03:25:01 +02:00
#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")
2022-06-11 12:57:39 +02:00
out+=("^sep($OTHERTOOLS)")
2022-06-08 21:45:29 +02:00
out+=("Tint2 Menu,^pipe(jgtint2-pipe)")
2022-06-11 12:57:39 +02:00
out+=("$WALLPAPER,^pipe(jgwallpaperchanger)")
out+=("Color Menu,colormenu")
2022-05-15 03:25:01 +02:00
out+=("^sep()")
2022-05-15 18:50:21 +02:00
#out+=("PREFERENCES")
2022-06-11 12:57:39 +02:00
LNG=${LANG:0:2}
if [[ -f "/usr/share/mabox-colorizer/help/$LNG.html" ]];then
out+=("$HELP,yhtml /usr/share/mabox-colorizer/help/$LNG.html 'Mabox Help - Colorizer'")
else
out+=("$HELP,yhtml /usr/share/mabox-colorizer/help/en.html 'Mabox Help - Colorizer'")
fi
2022-05-15 03:25:01 +02:00
### RUN
if [[ "$1" == "-s" ]]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
#out+=("^sep()")
#out+=(" ⮜ $LEFTPANEL,mb-jgtools places")
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_PADDING_TOP=${jgtools_padding:-0}
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 + 128))
#TEMP POSITION:
MENU_VALIGN="top"
2022-05-15 14:16:06 +02:00
MENU_MARGIN_Y="60"
2022-05-15 03:25:01 +02:00
mkconfigfile
#THUMB="$(DISPLAY=:0 scrot -t 220x100 -o $HOME/.config/mabox/colorizer.png -e 'echo $m')"
cat <<EOF > ${MENU_ITEMS}
2022-05-15 14:16:06 +02:00
@icon,,$((jgtools_padding + 4)),$((jgtools_padding + 4)),270,120,4,left,top,,,/usr/share/mabox-colorizer/img/colorizer.png
2022-05-15 03:25:01 +02:00
$(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[@]}"