aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2005-06-23 18:43:53 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2005-06-23 18:43:53 +0000
commitea6844bd11a4f55938d7612cff341ecd5ddd862f (patch)
tree3758e05d4b21ed24a9a557aff34e1343ceca9b06 /scripts
parent31acec5e47a5fbef13fdc6b875b119eb9d0a89de (diff)
made this script an actual, useful config switcher
svn path=/trunk/; revision=3241
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/config-switcher.sh80
1 files changed, 74 insertions, 6 deletions
diff --git a/scripts/config-switcher.sh b/scripts/config-switcher.sh
index 04e77f52..7276291d 100755
--- a/scripts/config-switcher.sh
+++ b/scripts/config-switcher.sh
@@ -1,10 +1,78 @@
#!/bin/sh
-# location of plist that Pd reads
-PLIST_ROOT=~/Library/Preferences/org.puredata.pd
-PLIST=$PLIST_ROOT.plist
-# which config to use (first argument)
-CONFIG=$1
+#==============================================================================#
+# functions
-cp -f "$PLIST_ROOT.$CONFIG.plist" "$PLIST"
+print_usage() {
+ echo "Usage: "
+ echo "To select a config file:"
+ echo " $0 select CONFIG_NAME"
+ echo "To save the current config to file:"
+ echo " $0 save CONFIG_NAME"
+ echo "To delete the current config:"
+ echo " $0 delete CONFIG_NAME"
+ echo "To list existing configs:"
+ echo " $0 list"
+ exit
+}
+
+#==============================================================================#
+# THE PROGRAM
+
+# location of pref file that Pd reads
+case `uname` in
+ Darwin)
+ CONFIG_DIR=~/Library/Preferences
+ CONFIG_FILE=org.puredata.pd.plist
+ ;;
+ *)
+ CONFIG_DIR=~
+ CONFIG_FILE=.pdrc
+ ;;
+esac
+
+# everything happens in this dir
+cd $CONFIG_DIR
+
+if [ $# -gt 1 ]; then
+ save_file="$CONFIG_FILE-$2"
+ case $1 in
+ select)
+ if [ -e "$save_file" ]; then
+ test -e "$CONFIG_FILE" && mv "$CONFIG_FILE" /tmp
+ ln -s "$save_file" "$CONFIG_FILE" && \
+ echo "Pd config \"$save_file\" selected."
+ else
+ echo "\"$save_file\" doesn't exist. No action taken."
+ fi
+ ;;
+ save)
+ if [ -e "$CONFIG_DIR/$CONFIG_FILE" ]; then
+ cp "$CONFIG_FILE" "$save_file" && \
+ echo "Pd config \"$2\" saved."
+ else
+ echo "\"$CONFIG_FILE\" doesn't exist. No action taken."
+ fi
+ ;;
+ delete)
+ if [ -e "$save_file" ]; then
+ rm "$save_file" && \
+ echo "Pd config \"$save_file\" deleted."
+ else
+ echo "\"$CONFIG_FILE\" doesn't exist. No action taken."
+ fi
+ ;;
+ *) print_usage ;;
+ esac
+else
+ case $1 in
+ list)
+ echo "Available configs:"
+ \ls -1 ${CONFIG_FILE}*
+ ;;
+ *)
+ print_usage
+ ;;
+ esac
+fi