#!/bin/bash
# jgtint2launcher - Add/Remove applications to Tint2 panel launcher
#
case $LANG in
pl*)
TITLE="Dodaj/usuń programy do panelu Tint2"
TYPE_TO_SEARCH="Pisz aby Wyszukać"
CURRENT="Wyzwalacze"
OPENDIR="Otwórz"
ADD="dodaj"
DEL="usuń"
ALL="wszystkie";;
es*)
TITLE="Add/Remove Tint2 panel launchers"
TYPE_TO_SEARCH="Buscar"
CURRENT="Launchers"
OPENDIR="Abrir"
ADD="add"
DEL="remove"
ALL="all";;
*)
TITLE="Add/Remove Tint2 panel launchers"
TYPE_TO_SEARCH="Type to Search"
CURRENT="Launchers"
OPENDIR="Open"
ADD="add"
DEL="remove"
ALL="all";;
esac
: ${JGMENU_RESOURCE_OPENER=xdg-open}
LAUNCHERDIR="$HOME/.config/tint2/launcherapps"
mkdir -p ${LAUNCHERDIR}
APPSDIR="/usr/share/applications"
out+=("@text,,$(expr $jgtools_padding + 10),$(expr $jgtools_padding + 10),300,20,4,left,top,auto,#111111,$TITLE")
out+=("@search,,34,29,292,20,4,left,top,auto,#262626,\"\"\" $TYPE_TO_SEARCH\"\"\"")
out+=("^sep($CURRENT)")
out+=(" $OPENDIR (~/.config/tint2/launcherapps),${JGMENU_RESOURCE_OPENER} $LAUNCHERDIR")
out+=("^sep()")
a=0
for item in "$LAUNCHERDIR"/*.desktop; do
if [[ -f $item ]]; then
((a++))
filename=${item##*/}
filename=${filename^}
out+=("$DEL ${filename%.*},rm $item;killall -SIGUSR1 tint2;jgtint2launcher")
fi
done
if [[ $a -gt 1 ]]; then
out+=("^sep()")
out+=("$DEL $ALL: ($a),rm -f $LAUNCHERDIR/*.desktop;killall -SIGUSR1 tint2;jgtint2launcher")
fi
out+=("^sep($ADD...)")
out+=(" $OPENDIR (/usr/share/applications),${JGMENU_RESOURCE_OPENER} $APPSDIR")
out+=("^sep()")
for item in "$APPSDIR"/*.desktop; do
filename=${item##*/}
filename=${filename^}
out+=("$ADD ${filename%.*},cp \"$item\" $LAUNCHERDIR;killall -SIGUSR1 tint2;jgtint2launcher")
done
### RUN
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
MENU_PADDING_TOP=48
MENU_HALIGN="center"
MENU_VALIGN="center"
jgmenu_icon_size=0
JGWIDTH=300
MENU_HEIGHT_MAX=480
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
mkconfigfile
cat < ${MENU_ITEMS}
$(printf '%s\n' "${out[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
printf '%s\n' "${out[@]}"
exit 0