aboutsummaryrefslogtreecommitdiff
path: root/JsonMenu_Scripts/ls.json.sh
blob: 7bd09e2db3ca1316f5273f9071c5a5cf76c2fabc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
DIR=${1}
if [ "$1" == "" ] ; then
  DIR=`pwd`
fi

ls ${DIR} > /tmp/.tmp.lines.$$ 
while read name
do
  if [ -n "${OUT}" ] ; then
    OUT="${OUT},"
  fi
  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