|
|
@ -4,6 +4,8 @@ |
|
|
|
# shellcheck source=scripts/core/sxmo_common.sh |
|
|
|
# shellcheck source=scripts/core/sxmo_common.sh |
|
|
|
. "$(dirname "$0")/sxmo_common.sh" |
|
|
|
. "$(dirname "$0")/sxmo_common.sh" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set -e |
|
|
|
|
|
|
|
|
|
|
|
DIR="$1" |
|
|
|
DIR="$1" |
|
|
|
[ -z "$DIR" ] && DIR="$HOME" |
|
|
|
[ -z "$DIR" ] && DIR="$HOME" |
|
|
|
cd "$DIR" || exit 1 |
|
|
|
cd "$DIR" || exit 1 |
|
|
@ -12,17 +14,27 @@ SORT= |
|
|
|
REVERSE= |
|
|
|
REVERSE= |
|
|
|
|
|
|
|
|
|
|
|
sort_loop() { |
|
|
|
sort_loop() { |
|
|
|
CHOICES="$([ -z "$SORT" ] && echo "date" || echo "name")\n$([ -z "$REVERSE" ] && echo "desc" || echo "asc")" |
|
|
|
CHOICES="$([ -z "$SORT" ] && printf "date" || printf "name")\n$([ -z "$REVERSE" ] && printf "desc" || printf "asc")\n" |
|
|
|
|
|
|
|
|
|
|
|
PICKED="$( |
|
|
|
PICKED="$( |
|
|
|
printf %b "$CHOICES" | |
|
|
|
printf %b "$CHOICES" | |
|
|
|
sxmo_dmenu.sh -p "Sort" -i |
|
|
|
sxmo_dmenu.sh -p "Sort" -i |
|
|
|
)" |
|
|
|
)" |
|
|
|
|
|
|
|
|
|
|
|
echo "$PICKED" | grep -q "date" && SORT="--sort=t" |
|
|
|
case "$PICKED" in |
|
|
|
echo "$PICKED" | grep -q "name" && SORT= |
|
|
|
"date") |
|
|
|
echo "$PICKED" | grep -q "desc" && REVERSE="-r" |
|
|
|
SORT="--sort=t" |
|
|
|
echo "$PICKED" | grep -q "asc" && REVERSE= |
|
|
|
;; |
|
|
|
|
|
|
|
"name") |
|
|
|
|
|
|
|
SORT= |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
"desc") |
|
|
|
|
|
|
|
REVERSE="-r" |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
"asc") |
|
|
|
|
|
|
|
REVERSE= |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
esac |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -36,19 +48,30 @@ while true; do |
|
|
|
DIR="$TRUNCATED..." |
|
|
|
DIR="$TRUNCATED..." |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PICKED="$( |
|
|
|
PICKED="$( |
|
|
|
echo "$CHOICES" | |
|
|
|
printf %b "$CHOICES" | |
|
|
|
sxmo_dmenu.sh -p "$DIR" -i |
|
|
|
sxmo_dmenu.sh -p "$DIR" -i |
|
|
|
)" || exit |
|
|
|
)" |
|
|
|
|
|
|
|
|
|
|
|
echo "$PICKED" | grep "Sort By" && sort_loop |
|
|
|
case "$PICKED" in |
|
|
|
echo "$PICKED" | grep "Open in terminal" && cd "$(pwd)" && sxmo_terminal.sh |
|
|
|
"Sort By") |
|
|
|
echo "$PICKED" | grep "Close Menu" && exit 0 |
|
|
|
sort_loop |
|
|
|
echo "$PICKED" | grep "Reload" && continue |
|
|
|
;; |
|
|
|
|
|
|
|
"Open in terminal") |
|
|
|
|
|
|
|
cd "$(pwd)" && sxmo_terminal.sh && continue |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
"Close Menu") |
|
|
|
|
|
|
|
exit 0 |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
"Reload") |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
\*) |
|
|
|
|
|
|
|
sxmo_open.sh -a ./* |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
*) |
|
|
|
[ -d "$PICKED" ] && cd "$PICKED" && continue |
|
|
|
[ -d "$PICKED" ] && cd "$PICKED" && continue |
|
|
|
echo "$PICKED" | grep -E '^[*]$' && sxmo_open.sh -a ./* |
|
|
|
[ -f "$PICKED" ] && sxmo_open.sh -a "$PICKED" |
|
|
|
if [ -f "$PICKED" ] || [ "$PICKED" = "Open in terminal" ]; then |
|
|
|
;; |
|
|
|
sxmo_open.sh -a "$PICKED" |
|
|
|
esac |
|
|
|
fi |
|
|
|
|
|
|
|
done |
|
|
|
done |
|
|
|