mabox-pipemenus/usr/bin/mb-places

148 lines
4.0 KiB
Plaintext
Raw Normal View History

2021-11-11 01:27:47 +01:00
#!/bin/bash
# mb-places
#
. ~/.config/mabox/mabox.conf
PLACES="$HOME/.config/mabox/places.csv"
case $LANG in
pl*)
LABEL="Miejsca"
ROOTDIR="Katalog główny"
HOME_DIR="Katalog domowy"
2022-11-28 20:29:38 +01:00
MOUNTPOINTS="Dyski (Punkty montowania)"
2022-09-20 23:15:44 +02:00
SHOW_HIDDEN="Wyświetlanie ukrytych plików"
2021-11-11 01:27:47 +01:00
EDIT="Edytuj"
FILETOOLS="Narzędzia plikowe"
INST="Instaluj"
2023-01-12 12:26:41 +01:00
SETTINGS="Ustawienia"
2021-11-11 01:27:47 +01:00
;;
es*)
LABEL="Places"
2021-11-14 01:26:07 +01:00
ROOTDIR="Root Directory"
HOME_DIR="Home Directory"
2022-11-28 20:29:38 +01:00
MOUNTPOINTS="Discs (mount points)"
2021-11-11 01:27:47 +01:00
SHOW_HIDDEN="Show hidden files"
EDIT="Edit"
FILETOOLS="File Tools"
INST="Install"
2023-01-12 12:26:41 +01:00
SETTINGS="Settings"
2021-11-11 01:27:47 +01:00
;;
*)
LABEL="Places"
2021-11-14 01:26:07 +01:00
ROOTDIR="Root Directory"
HOME_DIR="Home Directory"
2022-11-28 20:29:38 +01:00
MOUNTPOINTS="Discs (mount points)"
2021-11-11 01:27:47 +01:00
SHOW_HIDDEN="Show hidden files"
EDIT="Edit"
FILETOOLS="File Tools"
INST="Install"
2023-01-12 12:26:41 +01:00
SETTINGS="Settings"
2021-11-11 01:27:47 +01:00
;;
esac
if [ ! -f ${PLACES} ]; then
cat <<EOF > ${PLACES}
^sep($LABEL)
2023-01-12 12:26:41 +01:00
 $HOME_DIR (<b>~</b>),^pipe(jgbrowser),folder-home
 $(basename $(xdg-user-dir DOWNLOAD)),^pipe(jgbrowser $(xdg-user-dir DOWNLOAD)),folder-download
 $(basename $(xdg-user-dir DOCUMENTS)),^pipe(jgbrowser $(xdg-user-dir DOCUMENTS)),folder-documents
 $(basename $(xdg-user-dir MUSIC)),^pipe(jgbrowser $(xdg-user-dir MUSIC)),folder-music
 $(basename $(xdg-user-dir PICTURES)),^pipe(jgbrowser $(xdg-user-dir PICTURES)),folder-pictures
 $(basename $(xdg-user-dir VIDEOS)),^pipe(jgbrowser $(xdg-user-dir VIDEOS)),folder-video
2021-11-11 01:27:47 +01:00
^sep()
2023-01-12 12:26:41 +01:00
 ~/.config,^pipe(jgbrowser ~/.config),folder
2021-11-11 01:27:47 +01:00
EOF
fi
mapfile -t out < "$PLACES"
2022-11-28 20:29:38 +01:00
out+=("^sep($MOUNTPOINTS)")
while read DEVICE SIZE USED FREE PERCENT MOUNT
do
[[ "${#MOUNT}" -gt "10" ]] && MOUNTLBL=${MOUNT##*/} || MOUNTLBL=${MOUNT}
[[ "${#MOUNTLBL}" -gt "10" ]] && MOUNTLBL=${MOUNTLBL:0:9}
[[ "${MOUNT}" = *"media"* ]] && ICON="drive-removable-media-usb" || ICON="drive-harddisk"
out+=("$MOUNTLBL,^pipe(jgbrowser ${MOUNT}),$ICON")
done < <(df -h | grep -v "boot" | grep '^/dev')
2023-01-12 12:26:41 +01:00
out2+=("^tag(inst)")
2021-11-11 01:27:47 +01:00
out+=("^sep($FILETOOLS)")
2022-11-28 20:29:38 +01:00
if hash pcmanfm &>/dev/null; then
2022-11-10 18:56:41 +01:00
out+=("PCManFM,pcmanfm,file-manager")
2022-11-28 20:29:38 +01:00
fi
if hash thunar &>/dev/null; then
out+=("Thunar,thunar,file-manager")
fi
if hash fsearch &>/dev/null; then
2022-11-10 18:56:41 +01:00
out+=("FSearch,fsearch,search")
2022-11-28 20:29:38 +01:00
fi
2021-11-11 01:27:47 +01:00
if hash doublecmd &>/dev/null; then
out+=("Double Commander,doublecmd,doublecmd")
else
out2+=("$INST Double Commander,pamac-installer doublecmd-gtk2,package-manager-icon")
fi
if hash qdirstat &>/dev/null; then
out+=("QDirStat,qdirstat,qdirstat")
else
out2+=("$INST QDirStat,pamac-installer qdirstat,package-manager-icon")
fi
2023-01-12 12:26:41 +01:00
if (( ${#out2[@]} > 1 )); then
2021-11-11 01:27:47 +01:00
out+=("^sep()")
out+=("$INST ...,^checkout(inst),package-manager-icon ")
fi
2023-01-12 12:26:41 +01:00
out+=("^sep($SETTINGS)")
[[ $jgbrowser_show_hidden = false ]] && out+=("<i><s>$SHOW_HIDDEN</s></i>,mb-setvar jgbrowser_show_hidden=true;mb-places -s") || out+=("$SHOW_HIDDEN,mb-setvar jgbrowser_show_hidden=false;mb-places -s")
out+=(" $EDIT $LABEL,xdg-open $PLACES,geany")
2021-11-11 01:27:47 +01:00
### RUN
if [[ "$1" == "-s" || "$1" == "ipc" ]]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
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"
if [[ "$1" == "ipc" ]]; then
POSITION_MODE="ipc"
else
POSITION_MODE="fixed"
fi
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
2023-01-12 12:26:41 +01:00
icons=0
iconmargin=0
2021-11-11 01:27:47 +01:00
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[@]}"
if [[ $1 == "-r" ]]; then
printf '%s\n' "^sep()"
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_jgdesktops=false;mb-jgtools places"
fi
printf '%s\n' "${out2[@]}"