--- /usr/bin/activity.orig 2011-05-29 17:10:04.000000000 +1000 +++ /usr/bin/activity 2011-07-03 16:25:09.000000000 +1000 @@ -20,7 +20,7 @@ # # $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $ -VERSION="1.1" +VERSION="1.1.1" D0="$HOME/.activities" @@ -312,7 +312,7 @@ cat << _KOKO Pass the activity name to save the current configuration to. The "current" activity will be also set to be that activity. -If it doesn't exist it will be created. +If it does not exist it will be created. _KOKO exit 1 fi @@ -333,7 +333,7 @@ { if [ -z "$1" ] ; then cat << _KOKO -Pass the new activity as the first argument. If it doesn't exist it will +Pass the new activity as the first argument. If it does not exist it will be created. _KOKO exit 1 @@ -356,7 +356,35 @@ do_list() { +if [ "$(whoami)" = 'root' ]; then + echo "You should not run this as root." + exit 1; +fi + ( + FOUND=0 + cd $DSTDIR0 + for i in * ; do + if [ -d "$i" ] ; then + echo "$i" + FOUND=1 + fi + done + # If there is no activity, return the default as if it existed + if [ "$FOUND" = "0" ] ; then + echo "$DEFAULTACTIVITY" + fi + ) +} + +do_clist() +{ +if [ "$(whoami)" = 'root' ]; then + echo "You should not run this as root." + exit 1; +fi ( + echo "List of stored activities:" + echo "=========================================================" FOUND=0 cd $DSTDIR0 for i in * ; do @@ -365,6 +393,8 @@ FOUND=1 fi done + echo "=========================================================" + echo "Current activity: `cat $D0/$DSTDIR0/current`" # If there is no activity, return the default as if it existed if [ "$FOUND" = "0" ] ; then echo "$DEFAULTACTIVITY" @@ -434,13 +464,13 @@ if [ -z "$1" ] || [ -z "$2" ] ; then cat << _KOKO Pass the source and destination name as first and second parameter -repsectively. +respectively. _KOKO exit 1 fi if ! check_exist "$1" ; then - echo "Activity $1 doesn't exist" + echo "Activity $1 does not exist" exit 1 fi @@ -490,7 +520,7 @@ check_exist_error "$ACT" if ! [ "x$1" = "x-f" ] ; then - read -p "Are you sure? (type yes to continue) " ans + read -p "Are you sure? (type "yes" to continue) " ans if ! [ "$ans" = "yes" ] ; then echo "Aborted" return @@ -525,6 +555,27 @@ restore2 "$CURRENT" } +do_qload() +{ + if [ -z "$1" ] ; then + cat << _KOKO +Pass the new activity as the first argument. +_KOKO + exit 1 + fi + if [ "x$1" = "x-f" ] ; then + ACT="$2" + else + ACT="$1" + fi + + check_exist_error "$1" + + echo "Loading "$1" activity without saving changes" + + restore2 "$ACT" +} + do_runstart() { if [ "x$1" = "x" ] ; then @@ -562,10 +613,12 @@ create ACTIVITY Create a new (empty) activity. current Print the current activity name. delete [-f] ACTIVITY Same as remove. - help This help. - list List available activities. + help This help screen. + clist List available activities. load [-f] SRC Load activity SRC. If -f is used then it will be allowed to re-load the current activity. + qload SRC Quickly loads the activity without saving any + changes to the previous activity. (devs only) new ACTIVITY Same as create. reload Reload current activity without storing first. remove [-f] ACTIVITY Remove activity ACTIVITY. If -f is used then there @@ -593,6 +646,9 @@ # Just load do_load "$2" "$3" ;; + qload) + do_qload "$2" "$3" + ;; change) # Save the current and load the next do_change "$2" @@ -600,6 +656,9 @@ list) do_list ;; + clist) + do_clist + ;; current) do_current ;; @@ -631,7 +690,7 @@ do_version ;; *) - echo "Bad command: $1" + do_help ;; esac