mabox-pipemenus/usr/bin/mbhelper

100 lines
2.5 KiB
Plaintext
Raw Normal View History

2021-05-28 02:51:24 +02:00
#!/bin/bash
# mbhelper - command palette like menu, search and run, quick access to
# all important config tools, edit config files, show keybord shortcuts
# favorites, online resources and more.
#
case $LANG in
pl*)
LNGDIR="pl"
TYPE_TO_SEARCH="pisz aby wyszukać"
2021-09-04 22:53:28 +02:00
ME="Paleta komend (to menu)"
EDIT="Dostosuj..."
2021-08-12 22:05:22 +02:00
RESET="Przywróć domyślne"
2022-05-01 13:42:39 +02:00
QUICKCONFIG="Szybki dostęp do plików i katalogów konfiguracyjnych"
2021-05-28 02:51:24 +02:00
;;
es*)
LNGDIR="en"
TYPE_TO_SEARCH="type to search"
2021-09-04 22:53:28 +02:00
ME="CMD Palette (this menu)"
EDIT="Edit..."
2021-08-12 22:05:22 +02:00
RESET="Reset to default"
2021-05-28 02:51:24 +02:00
;;
*)
LNGDIR="en"
TYPE_TO_SEARCH="type to search"
2021-09-05 01:48:38 +02:00
ME="CMD Palette (this menu)"
2021-09-04 22:53:28 +02:00
EDIT="Edit..."
2021-08-12 22:05:22 +02:00
RESET="Reset to default"
2022-05-01 13:42:39 +02:00
QUICKCONFIG="Quick access to config files and directories"
2021-05-28 02:51:24 +02:00
;;
esac
2021-08-12 22:05:22 +02:00
[[ -f "$HOME/.config/mabox/mbhelper.csv" ]] && CSVFILE="$HOME/.config/mabox/mbhelper.csv" TODEFAULT="$RESET,mbhelper reset"|| CSVFILE="/usr/share/mabox/lang/${LNGDIR}/.config/mabox/mbhelper.csv" TODEFAULT=""
2021-05-28 02:51:24 +02:00
2021-08-12 22:05:22 +02:00
run() {
2021-05-28 02:51:24 +02:00
### RUN
2021-06-09 12:25:27 +02:00
if [[ $1 = "-s" ]]; then
2021-09-24 01:40:09 +02:00
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
2021-05-28 02:51:24 +02:00
. $HOME/.config/mabox/mabox.conf
2021-05-31 15:00:35 +02:00
MENU_PADDING_TOP=$((jgtools_padding+24))
2021-05-28 02:51:24 +02:00
MENU_HALIGN="center"
MENU_VALIGN="top"
MENU_MARGIN_Y=40
jgmenu_icon_size=0
2021-09-04 22:53:28 +02:00
JGWIDTH=400
MENU_HEIGHT_MAX=600
2021-05-28 02:51:24 +02:00
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
mkconfigfile
2022-05-01 13:19:43 +02:00
CNFDIRFILE="$HOME/.config/mabox/configdir.csv"
> $CNFDIRFILE
while read i; do
echo "~/.config${i#*config},xdg-open ${i}" >> $CNFDIRFILE
done < <(tree -aif -I chromium -I "Local Storage" -I IndexedDB -I registry -I icons -I "*cache*" -I "*Cach*" --noreport ~/.config/)
2021-05-28 02:51:24 +02:00
cat <<EOF > ${MENU_ITEMS}
2022-05-01 17:27:01 +02:00
@search,,$((jgtools_padding + 24)),$((jgtools_padding + 4)),292,20,4,left,top,auto,#262626,"""<big></big> <i>$TYPE_TO_SEARCH</i>"""
2021-08-12 22:05:22 +02:00
^sep($ME)
$EDIT,mbhelper edit
${TODEFAULT}
2021-09-04 22:53:28 +02:00
. $CSVFILE
2022-05-01 13:42:39 +02:00
^sep($QUICKCONFIG)
~/.bashrc,xdg-open ~/.bashrc
2022-05-01 13:19:43 +02:00
. $CNFDIRFILE
2021-08-12 22:05:22 +02:00
2021-05-28 02:51:24 +02:00
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
2021-08-12 22:05:22 +02:00
}
2021-05-28 02:51:24 +02:00
2021-08-12 22:05:22 +02:00
edit() {
if [[ -f "$HOME/.config/mabox/mbhelper.csv" ]];then
2022-08-17 14:19:31 +02:00
xdg-open "$HOME/.config/mabox/mbhelper.csv"
2021-08-12 22:05:22 +02:00
else
cp "/usr/share/mabox/lang/${LNGDIR}/.config/mabox/mbhelper.csv" "$HOME/.config/mabox/mbhelper.csv"
2022-08-17 14:19:31 +02:00
xdg-open "$HOME/.config/mabox/mbhelper.csv"
2021-08-12 22:05:22 +02:00
fi
}
reset() {
rm "$HOME/.config/mabox/mbhelper.csv"
}
case "$1" in
-e|edit) edit;;
-r|reset) reset;;
*) run "$1";;
esac
2021-05-28 02:51:24 +02:00