mb-jgtools/bin/jgbrowser

54 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
2020-03-02 23:32:09 +01:00
# Daniel Napora 2020 <napcok@gmail.com>
# Read a directory to an array and sort it directories first.
2020-02-17 17:14:08 +01:00
case $LANG in
pl*)
DIRECTORIES="Katalogi"
FILES="Pliki"
OPENDIR="Otwórz w menadżerze plików"
OPENTERM="Otwórz w terminalu"
;;
es*)
DIRECTORIES="Directorios"
FILES="Archivos"
OPENDIR="Abrir Gestor de archivos aquí"
OPENTERM="Abrir terminal aquí"
;;
2020-02-17 17:14:08 +01:00
*)
DIRECTORIES="Directories"
FILES="Files"
OPENDIR="Open filemanager here"
OPENTERM="Open terminal here"
;;
esac
: ${JGMENU_RESOURCE_OPENER=xdg-open}
DIRECTORY=${1:-$HOME}
2020-02-09 16:52:47 +01:00
# If '$DIRECTORY' is '/', unset it to avoid '//'.
[[ $DIRECTORY == / ]] && DIRECTORY=
for item in "$DIRECTORY"/*; do
if [[ -d $item ]]; then
dirs+=("${item##*/},^pipe(jgbrowser \"$DIRECTORY/${item##*/}\")")
else
2020-02-09 16:52:47 +01:00
if [[ -f $item ]]; then
files+=("${item##*/},xdg-open \"$DIRECTORY/${item##*/}\"")
fi
2020-02-09 16:52:47 +01:00
fi
done
2020-02-09 16:52:47 +01:00
printf "%b\n" "^sep(<small><i>${DIRECTORY:-/}</i></small>)"
2020-07-22 17:02:26 +02:00
printf "%b\n" " $OPENDIR,${JGMENU_RESOURCE_OPENER} \"${DIRECTORY:-/}\""
printf "%b\n" " $OPENTERM,exo-open --launch TerminalEmulator --working-directory=\"${DIRECTORY:-/}\""
2020-02-09 16:52:47 +01:00
if [ ${#dirs[@]} -ne 0 ]; then
2020-02-17 17:14:08 +01:00
printf "%b\n" "^sep($DIRECTORIES)"
2020-02-09 16:52:47 +01:00
printf '%s\n' "${dirs[@]}"
fi
if [ ${#files[@]} -ne 0 ]; then
2020-02-17 17:14:08 +01:00
printf "%b\n" "^sep($FILES)"
2020-02-09 16:52:47 +01:00
printf '%s\n' "${files[@]}"
fi