From db536f42f30514112944892f209520a2ac5a65c2 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 29 Jun 2016 17:38:14 -0400 Subject: Create a directory for placing sample JSON menu generation scripts, and add one (incomplete yet) for listing the contents of the current directory (home dir ususally) --- JsonMenu_Scripts/ls.json.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 JsonMenu_Scripts/ls.json.sh (limited to 'JsonMenu_Scripts/ls.json.sh') diff --git a/JsonMenu_Scripts/ls.json.sh b/JsonMenu_Scripts/ls.json.sh new file mode 100755 index 00000000..9a6ab847 --- /dev/null +++ b/JsonMenu_Scripts/ls.json.sh @@ -0,0 +1,10 @@ +#!/bin/sh +cmd="ls $1" +OUT="" +for name in `${cmd}`; do + if [ "${OUT}" != "" ] ; then + OUT="${OUT}," + fi + OUT="${OUT} \"${name}\" : { \"type\" : \"item\", \"action\" : \"${name}\"}" +done +echo "{ ${OUT} }" -- cgit From 08f6b215cdaa43cb27d1a46343fbaf1a43031017 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 30 Jun 2016 09:24:59 -0400 Subject: Update the new ls.json.sh script so ti works properly now. --- JsonMenu_Scripts/ls.json.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'JsonMenu_Scripts/ls.json.sh') 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} }" -- cgit From 702d651bad7892126fdf82499f25e6e418499366 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 30 Jun 2016 09:39:01 -0400 Subject: Finish up the new JSON recursive menu system as well as the test script for listing the contents of a directory recursively. --- JsonMenu_Scripts/ls.json.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'JsonMenu_Scripts/ls.json.sh') diff --git a/JsonMenu_Scripts/ls.json.sh b/JsonMenu_Scripts/ls.json.sh index 7bd09e2d..5b4680ed 100755 --- a/JsonMenu_Scripts/ls.json.sh +++ b/JsonMenu_Scripts/ls.json.sh @@ -13,7 +13,7 @@ do 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}\"}" + OUT="${OUT} \"${name}\" : { \"type\" : \"item\", \"icon\":\"unknown\", \"action\" : \"xdg-open ${DIR}/${name}\"}" fi done < /tmp/.tmp.lines.$$ rm /tmp/.tmp.lines.$$ -- cgit From c1651e696d153428fe94b19e3550f8c3828a9852 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 30 Jun 2016 09:53:05 -0400 Subject: Fix some whitespace issues with the ls.json.sh script. --- JsonMenu_Scripts/ls.json.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'JsonMenu_Scripts/ls.json.sh') diff --git a/JsonMenu_Scripts/ls.json.sh b/JsonMenu_Scripts/ls.json.sh index 5b4680ed..626912cb 100755 --- a/JsonMenu_Scripts/ls.json.sh +++ b/JsonMenu_Scripts/ls.json.sh @@ -4,16 +4,16 @@ if [ "$1" == "" ] ; then DIR=`pwd` fi -ls ${DIR} > /tmp/.tmp.lines.$$ +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\"}" + OUT="${OUT} \"${name}\" : { \"type\" : \"jsonmenu\", \"exec\" : \"${0} \\\"${DIR}/${name}\\\"\", \"icon\":\"folder\"}" else - OUT="${OUT} \"${name}\" : { \"type\" : \"item\", \"icon\":\"unknown\", \"action\" : \"xdg-open ${DIR}/${name}\"}" + OUT="${OUT} \"${name}\" : { \"type\" : \"item\", \"icon\":\"unknown\", \"action\" : \"xdg-open \\\"${DIR}/${name}\\\"\"}" fi done < /tmp/.tmp.lines.$$ rm /tmp/.tmp.lines.$$ -- cgit