mabox-pipemenus/usr/bin/jgwallpapergenerate

149 lines
3.9 KiB
Plaintext
Raw Normal View History

2022-02-18 20:34:22 +01:00
#!/bin/bash
# jgwallpapergenerate - submenu to generate wallpapers
#
2022-02-20 09:13:12 +01:00
CONFIG_DIR="$HOME/.config/mbxutils/imgw"
CONFIG_FILE="$CONFIG_DIR/imgw.cfg"
mkdir -p $CONFIG_DIR
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
show_preview=yes
EOF
fi
source <(grep = $CONFIG_FILE)
2022-02-18 20:34:22 +01:00
case $LANG in
pl*)
TITLE="Generator tapet (ImageMagick)"
RANDCOLORS="Losowe kolory"
PICKCOLORS="Wybór kolorów..."
WALLPAPERMENU="Menu Tapety"
2022-02-20 09:13:12 +01:00
RANDOMEFFECT="<b>Losowy</b> efekt"
2022-02-18 20:34:22 +01:00
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="Wygenerowane obrazy"
OPENDIR="Otwórz katalog"
EMPTYDIR="Opróżnij katalog"
SIZE="rozmiar"
2022-02-20 09:13:12 +01:00
SETTINGS="Ustawienia"
PREVIEW="Pokaż podgląd"
YES="tak"
NO="nie"
2022-02-18 20:34:22 +01:00
;;
*)
TITLE="Wallpaper Generator (ImageMagick)"
RANDCOLORS="Random colors"
PICKCOLORS="Pick colors..."
WALLPAPERMENU="Wallpapers Menu"
2022-02-20 09:13:12 +01:00
RANDOMEFFECT="<b>Random</b> effect"
2022-02-18 20:34:22 +01:00
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"
SIZE="size"
2022-02-20 09:13:12 +01:00
SETTINGS="Settings"
PREVIEW="Show preview?"
YES="yes"
NO="no"
2022-02-18 20:34:22 +01:00
;;
esac
. $HOME/.config/mabox/mabox.conf
DIR="$(xdg-user-dir PICTURES)/mb-canvas"
files="$(ls ${DIR}|wc -l)"
du="$(du -sh ${DIR}|awk '{print $1}')"
me="jgwallpapergenerate -s"
2022-02-20 09:13:12 +01:00
[[ "$show_preview" == "yes" ]] && l_show_preview="${YES}" || l_show_preview="${NO}"
2022-02-18 20:34:22 +01:00
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")
2022-02-20 09:13:12 +01:00
out+=("^sep()")
out+=("$RANDOMEFFECT,mb-canvas -Ra;$me")
2022-02-18 20:34:22 +01:00
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")
2022-02-20 09:13:12 +01:00
out+=("$PLASMA,mb-canvas -ap;$me")
2022-02-18 20:34:22 +01:00
if [ "$files" -gt "0" ]; then
out+=("\"\"\"^sep($IMAGES: $files - $SIZE: ${du})\"\"\"")
out+=("$OPENDIR,xdg-open $DIR")
out+=("$EMPTYDIR,rm ${DIR}/*.png;$me")
fi
2022-02-20 09:13:12 +01:00
out+=("^sep($SETTINGS)")
out+=("$PREVIEW [ <b>${l_show_preview}</b> ],^checkout(preview)")
out2+=("^tag(preview)")
out2+=("^sep($PREVIEW)")
out2+=("$YES ,mb-setvar show_preview=yes $CONFIG_FILE;$me")
out2+=("$NO,mb-setvar show_preview=no $CONFIG_FILE;$me")
2022-02-18 20:34:22 +01:00
### RUN
if [[ "$1" == "-s" ]]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
out+=("^sep()")
out+=(" ⮜ $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
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
$(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[@]}"