aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xJsonMenu_Scripts/ls.json.sh22
1 files changed, 16 insertions, 6 deletions
diff --git a/JsonMenu_Scripts/ls.json.sh b/JsonMenu_Scripts/ls.json.sh
index 9a6ab847..7bd09e2d 100755
--- a/JsonMenu_Scripts/ls.json.sh
+++ b/JsonMenu_Scripts/ls.json.sh
@@ -1,10 +1,20 @@
#!/bin/sh
-cmd="ls $1"
-OUT=""
-for name in `${cmd}`; do
- if [ "${OUT}" != "" ] ; then
+DIR=${1}
+if [ "$1" == "" ] ; then
+ DIR=`pwd`
+fi
+
+ls ${DIR} > /tmp/.tmp.lines.$$
+while read name
+do
+ if [ -n "${OUT}" ] ; then
OUT="${OUT},"
fi
- OUT="${OUT} \"${name}\" : { \"type\" : \"item\", \"action\" : \"${name}\"}"
-done
+ if [ -d "${DIR}/${name}" ] ; then
+ OUT="${OUT} \"${name}\" : { \"type\" : \"jsonmenu\", \"exec\" : \"${0} ${DIR}/${name}\", \"icon\":\"folder\"}"
+ else
+ OUT="${OUT} \"${name}\" : { \"type\" : \"item\", \"icon\":\"unknown\", \"action\" : \"${name}\"}"
+ fi
+done < /tmp/.tmp.lines.$$
+rm /tmp/.tmp.lines.$$
echo "{ ${OUT} }"
bgstack15