aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/generate-libdir-metafile.sh74
1 files changed, 74 insertions, 0 deletions
diff --git a/scripts/generate-libdir-metafile.sh b/scripts/generate-libdir-metafile.sh
new file mode 100755
index 00000000..78c3fe83
--- /dev/null
+++ b/scripts/generate-libdir-metafile.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+# this script is used to generate a mylibrary/mylibrary.pd meta file. This
+# file is read for relevant meta data when a libdir is opened. (That's the
+# plan at least) <hans@at.or.at>
+
+# keeps track of where the last bit of text was printed so that new text is
+# not printed on top of existing text
+Y=10
+
+# Usage: print_pd_text($to_file, $meta_type, $text_to_print)
+function print_pd_text ()
+{
+ file_name="$1"; shift
+ meta_type="$1"; shift
+ echo "#X text 10 $Y ${meta_type}: $@;" >> "$file_name"
+ ((Y=Y+20))
+}
+
+if [ $# -lt 2 ]; then
+ echo "Usage: $0 BASE_DIR LIBNAME [ meta types ] "
+ echo " --author"
+ echo " --copyright"
+ echo " --description"
+ echo " --keywords"
+ echo " --license"
+else
+
+BASE_DIR="$1"; shift
+LIBNAME="$1"; shift
+libdir_file_name="${BASE_DIR}/${LIBNAME}/${LIBNAME}.pd"
+# create pd file
+touch "${libdir_file_name}"
+
+# create .pd header with subpatch called "PDDP_META"
+echo "#N canvas 10 10 200 200 10;" >> "${libdir_file_name}"
+echo "#N canvas 20 20 420 300 PDDP_META 0;" >> "${libdir_file_name}"
+#N canvas 249 280 600 398 loc&precess 0;
+
+# add required meta fields
+print_pd_text "${libdir_file_name}" PDDP_META "this is a prototype of a libdir meta file"
+print_pd_text "${libdir_file_name}" NAME ${LIBNAME}
+
+
+# get meta data types:
+while [ $# -ge 1 ]; do
+ case $1 in
+ --author)
+ print_pd_text "${libdir_file_name}" AUTHOR "$2"
+ ;;
+ --copyright)
+ print_pd_text "${libdir_file_name}" COPYRIGHT "$2"
+ ;;
+ --description)
+ print_pd_text "${libdir_file_name}" DESCRIPTION "$2"
+ ;;
+ --keywords)
+ print_pd_text "${libdir_file_name}" KEYWORDS "$2"
+ ;;
+ --license)
+ print_pd_text "${libdir_file_name}" LICENSE "$2"
+ ;;
+ *)
+ echo "ERROR: unknown flag: $1 with data: $2"
+ ;;
+ esac
+ shift
+ shift
+done
+
+echo "#X restore 10 10 pd PDDP_META;" >> "${libdir_file_name}"
+
+
+fi