View Single Post
Posts: 502 | Thanked: 366 times | Joined on Jun 2010 @ /dev/null
#119
I've updated the script (from extras-devel) to:
- Include qload functionality (quick load, only for developers as you may lose shortcuts on your hildon-home.)
- Fixed up some typos (not really important if anything
- Decorated list when the user runs activity script from terminal, the command now is activity clist rather than activity list as that is what the GUI uses.
- Makes sure the user is not root when trying to list the activities in command line.
- Improper command will no longer say Bad command:, instead it will now print the help menu.
- Bumped the minor version to 1.1.1

Code:
--- /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
Any of you whom have used my previous patch on actman needs to realise that there's several flaws with the patch I've made, such as the fact that it littered the views.dump file along with gconf with extra bg-images. For starters the extra entries needs to be deleted and that needs to be applied for every affected desktop activity.

I will not condone the use of my previous patch (like I have already mentioned) nor will I condone the use of this one. The 9 desktop already works well without having to implement any extra lines to the code to make it work.
 

The Following User Says Thank You to tuxsavvy For This Useful Post: