mabox-pipemenus/usr/bin/jgwallpapergenerate

153 lines
5.3 KiB
Bash
Executable File

#!/bin/bash
# jgwallpapergenerate - submenu to generate wallpapers
#
CONFIG_DIR="$HOME/.config/mabox/tools"
CONFIG_FILE="$CONFIG_DIR/mb-canvas.cfg"
mkdir -p $CONFIG_DIR
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Imagetype extension avif or png
# avif (recommended) faster and much smaller size
extension=avif
# Show preview window, and then decide to set as wallpaper or not
# if no generated wallpaper will be applied immediately
# yes (recommended) or no
show_preview=yes
EOF
fi
source <(grep = $CONFIG_FILE)
case $LANG in
pl*)
_TITLE="<b>Generator</b> tapet <small>(ImageMagick)</small>"
_RANDCOLORS="Losowe kolory"
_PICKCOLORS="Wybór kolorów..."
_WALLPAPERMENU="Menu Tapety"
_RANDOMEFFECT="<b>Losowy</b> efekt"
_SOLID="<b>Jednolity</b> kolor"
_BLURRED="<b>Rozmycie</b>"
_LINEAR="Gradient <b>liniowy</b>"
_RADIAL="Gradient <b>promieniowy</b>"
_TWISTED="<b>Skręcony</b> gradient "
_BILINEAR="Gradient <b>dwuliniowy</b>"
_PLASMA="<b>Plazma</b>"
_ONECOLOR="(jeden kolor)"
_TWOCOLORS="(dwa kolory)"
_FOURCOLORS="(cztery kolory)"
_IMAGES="Utworzone obrazy"
_OPENDIR="Otwórz katalog"
_EMPTYDIR="Opróżnij katalog"
_SETTINGS="Ustawienia"
_PREVIEW="Pokaż podgląd"
_IMG_FORMAT="<i>format obrazków</i>"
_RECOMMENDED="(małe pliki - zalecany)"
;;
*)
_TITLE="Wallpaper <b>Generator</b> <small>(ImageMagick)</small>"
_RANDCOLORS="Random colors"
_PICKCOLORS="Pick colors..."
_WALLPAPERMENU="Wallpapers Menu"
_RANDOMEFFECT="<b>Random</b> effect"
_SOLID="<b>Solid</b> color"
_BLURRED="<b>Blurred</b>"
_LINEAR="<b>Linear</b> gradient"
_RADIAL="<b>Radial</b> gradient"
_TWISTED="<b>Twisted</b> gradient"
_BILINEAR="<b>Bilinear</b> gradient"
_PLASMA="<b>Plasma</b>"
_ONECOLOR="(pick one color)"
_TWOCOLORS="(pick two colors)"
_FOURCOLORS="(pick four colors)"
_IMAGES="Generated images"
_OPENDIR="Open directory"
_EMPTYDIR="Empty directory"
_SETTINGS="Settings"
_PREVIEW="Show preview"
_IMG_FORMAT="<i>image format</i>"
_RECOMMENDED="<i>(small filesize - recommended)</i>"
;;
esac
. $HOME/.config/mabox/mabox.conf
DIR="$(xdg-user-dir PICTURES)/imagick"
files="$(ls ${DIR}|wc -l)"
du="$(du -sh ${DIR}|awk '{print $1}')"
me="jgwallpapergenerate -s"
[[ "$1" != "-s" ]] && out+=("^sep($_TITLE)")
out+=("^sep($_RANDCOLORS)")
out+=("$_SOLID,mb-canvas -Ras;$me")
out+=("$_BLURRED,mb-canvas -RaB;$me")
out+=("$_LINEAR,mb-canvas -Ral;$me")
out+=("$_RADIAL,mb-canvas -Rar;$me")
out+=("$_TWISTED,mb-canvas -Rat;$me")
out+=("$_BILINEAR,mb-canvas -Rab;$me")
out+=("$_PLASMA,mb-canvas -Rap;$me")
out+=("^sep()")
out+=("$_RANDOMEFFECT,mb-canvas -Ra;$me")
out+=("^sep($_PICKCOLORS)")
out+=("$_SOLID $_ONECOLOR,mb-canvas -as;$me")
out+=("$_LINEAR $_TWOCOLORS,mb-canvas -al;$me")
out+=("$_RADIAL $_TWOCOLORS,mb-canvas -ar;$me")
out+=("$_TWISTED $_TWOCOLORS,mb-canvas -at;$me")
out+=("$_BILINEAR $_FOURCOLORS,mb-canvas -ab;$me")
out+=("$_PLASMA,mb-canvas -ap;$me")
if [ "$files" -gt "0" ]; then
out+=("\"\"\"^sep($_IMAGES: $files - ${du})\"\"\"")
out+=("$_OPENDIR,xdg-open $DIR")
out+=("$_EMPTYDIR,rm ${DIR}/*.*;$me")
fi
out+=("^sep($_SETTINGS)")
[[ "$show_preview" == "yes" ]] && out+=("<big>󰱒</big> $_PREVIEW,mb-setvar show_preview=no $CONFIG_FILE;${me}") || out+=("<big>󰄱</big> $_PREVIEW,mb-setvar show_preview=yes $CONFIG_FILE;${me}")
out+=("^sep($_IMG_FORMAT)")
[[ "$extension" == "avif" ]] && out+=("<big>綠</big> <b>avif</b> $_RECOMMENDED,mb-setvar extension=png $CONFIG_FILE;${me}") || out+=("<big>祿</big> avif $_RECOMMENDED,mb-setvar extension=avif $CONFIG_FILE;${me}")
[[ "$extension" == "png" ]] && out+=("<big>綠</big> <b>png</b>,mb-setvar extension=avif $CONFIG_FILE;${me}") || out+=("<big>祿</big> png,mb-setvar extension=png $CONFIG_FILE;${me}")
### RUN
if [[ "$1" == "-s" ]]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
out+=("^sep()")
out+=(" ${arrow_string_left} ${arrow_string_left} $_WALLPAPERMENU,jgwallpaperchanger -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_PADDING_TOP=${jgtools_padding:-0}
MENU_HALIGN="left"
jgmenu_icon_size=0
JGWIDTH=40
menu_margin_x=${submenu_spacing:-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 + 150))
THUMB=/usr/share/mabox/img/mb-canvas.png
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
@icon,,$((jgtools_padding )),$((jgtools_padding)),270,150,4,left,top,,,${THUMB}
@rect,,$((jgtools_padding)),$((jgtools_padding + 116)),270,28,0,left,top,#222222 20,#222222 70,
@text,,$((jgtools_padding + 201)),$((jgtools_padding + 92)),100,28,0,left,top,#DDDDDD 60,${WINCLR},<span size='41600' font_family='Ubuntu'><big>󱡄</big></span>
@text,,$((jgtools_padding + 4)),$((jgtools_padding + 116)),250,28,0,left,top,#FFFFFF ,${WINCLR},<span size='10400' font_family='Ubuntu'>$_TITLE </span>
$(printf '%s\n' "${out[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
printf '%s\n' "${out[@]}"