Actman

m (Running user scripts: typo)
(wikify slightly)
Line 1: Line 1:
-
== Desktop Activity Manager ==
 
-
 
-
=== Introduction ===
 
Desktop Activity Manager, or D-A-M, or DAM, or actman, is a command line tool and a status menu widget that allows saving and restoring of the destkop. There can be multiple saved desktops so it is possible to have different activities (desktop profiles) and switch between them by saving the current one and loading another.
Desktop Activity Manager, or D-A-M, or DAM, or actman, is a command line tool and a status menu widget that allows saving and restoring of the destkop. There can be multiple saved desktops so it is possible to have different activities (desktop profiles) and switch between them by saving the current one and loading another.
For discussion about actman visit [http://talk.maemo.org/showthread.php?t=47373 this thread].
For discussion about actman visit [http://talk.maemo.org/showthread.php?t=47373 this thread].
-
=== Status menu widget ===
+
== Status menu widget ==
The status menu widget is a front-end to the command line tool. While it doesn't have all its features it is easier to use and handles all common user actions.
The status menu widget is a front-end to the command line tool. While it doesn't have all its features it is easier to use and handles all common user actions.
-
[[Image:actman-screenshot1.png|300px]]
+
[[Image:actman-screenshot1.png|thumb|300px|alt=Screenshot of Actman main page|Main page]]
The main page includes the following actions:
The main page includes the following actions:
Line 18: Line 15:
* More: Shows more actions
* More: Shows more actions
-
When clicking "more", some more actions are shown:
 
-
[[Image:actman-ss-more.png|300px]]
+
[[Image:actman-ss-more.png|thumb|300px|alt=Screenshot of Actman more actions|More actions]]
-
Where:
+
When clicking "more", some more actions are shown:
* Store current: Saves the current activity without switching to a new one
* Store current: Saves the current activity without switching to a new one
* Reload current: Reloads the current activity
* Reload current: Reloads the current activity
-
=== Command line tool ===
+
== Command line tool ==
-
The command line tool is named "activity" and is installed in /usr/bin. It should be ran as user (and not as root!) and it includes a help screen:
+
The command line tool is named "activity" and is installed in <code>/usr/bin</code>. It should be run as user (and not as root!) and it includes a help screen:
-
~ $ /usr/bin/activity help   
+
 
-
Activity manager 1.1
+
<pre>
-
+
~ $ /usr/bin/activity help   
-
Available commands:
+
Activity manager 1.1
-
+
 
-
  change DEST Store current activity and load DEST.
+
Available commands:
-
  clone ACT1 ACT2 Create activity ACT2 as a clone of ACT1. Current
+
 
-
  activity will not be changed.
+
  change DEST Store current activity and load DEST.
-
  create ACTIVITY Create a new (empty) activity.
+
  clone ACT1 ACT2 Create activity ACT2 as a clone of ACT1. Current
-
  current Print the current activity name.
+
  activity will not be changed.
-
  delete [-f] ACTIVITY Same as remove.
+
  create ACTIVITY Create a new (empty) activity.
-
  help This help.
+
  current Print the current activity name.
-
  list List available activities.
+
  delete [-f] ACTIVITY Same as remove.
-
  load [-f] SRC Load activity SRC. If -f is used then it will be
+
  help This help.
-
  allowed to re-load the current activity.
+
  list List available activities.
-
  new ACTIVITY Same as create.
+
  load [-f] SRC Load activity SRC. If -f is used then it will be
-
  reload Reload current activity without storing first.
+
  allowed to re-load the current activity.
-
  remove [-f] ACTIVITY Remove activity ACTIVITY. If -f is used then there
+
  new ACTIVITY Same as create.
-
  will be no questions asked.
+
  reload Reload current activity without storing first.
-
  rename ACT1 ACT2 Rename activity ACT1 to ACT2.
+
  remove [-f] ACTIVITY Remove activity ACTIVITY. If -f is used then there
-
  runstart [ACTIVITY] Run scripts of entering an activity
+
  will be no questions asked.
-
  runend [ACTIVITY] Run scripts of ending an activity
+
  rename ACT1 ACT2 Rename activity ACT1 to ACT2.
-
  store DEST Store current activity as DEST.
+
  runstart [ACTIVITY] Run scripts of entering an activity
-
  version Print the version.
+
  runend [ACTIVITY] Run scripts of ending an activity
-
+
  store DEST Store current activity as DEST.
-
Activities are stored under /home/user/.activities
+
  version Print the version
 +
</pre>
 +
 
 +
Activities are stored under <code>/home/user/.activities</code>
To get a list of available activities use "list":
To get a list of available activities use "list":
-
~ $ /usr/bin/activity list  
+
 
-
car
+
<pre>
-
clean
+
~ $ /usr/bin/activity list  
-
empty
+
car
-
main
+
clean
-
main2
+
empty
-
main3
+
main
-
Tei
+
main2
-
Test
+
main3
-
test2
+
Tei
 +
Test
 +
test2
 +
</pre>
To save the current activity and switch to a new one use "change", etc.
To save the current activity and switch to a new one use "change", etc.
-
=== How it works ===
+
== How it works ==
TBD
TBD
-
=== Running user scripts ===
+
== Running user scripts ==
Since versions 1.1, actman has the ability to run user scripts.
Since versions 1.1, actman has the ability to run user scripts.
-
The scripts are stored under /home/user/.activities/scripts (which does not exist by default).
+
The scripts are stored under <code>/home/user/.activities/scripts</code> (which does not exist by default).
There are two kind of scripts:
There are two kind of scripts:
Line 88: Line 90:
The rationale behind this is to have initscript-like scripts that may start or stop services (kindA) or save/restore a widget's configuration (kindB).
The rationale behind this is to have initscript-like scripts that may start or stop services (kindA) or save/restore a widget's configuration (kindB).
-
==== Scripts associated with an activity ====
+
=== Scripts associated with an activity ===
-
Those scripts are installed in a directory named as the activity. For example, for the activity 'main' one can place scripts in /home/user/.activities/scripts/main. They will be ran when switching to or from that activity.
+
Those scripts are installed in a directory named as the activity. For example, for the activity 'main' one can place scripts in <code>/home/user/.activities/scripts/main</code>. They will be ran when switching to or from that activity.
-
==== Scripts not associated with an activity ====
+
=== Scripts not associated with an activity ===
-
They are installed in /home/user/.activities/scripts/always and are ran whenever an activity is switched.
+
They are installed in <code>/home/user/.activities/scripts/always</code> and are ran whenever an activity is switched.
-
==== Invocation ====
+
=== Invocation ===
Scripts are ran with the parameter "start" or "stop" depending on the invocation type. For example it is possible to create a script that connects/disconnects from the Internet when entering/leaving an activity:
Scripts are ran with the parameter "start" or "stop" depending on the invocation type. For example it is possible to create a script that connects/disconnects from the Internet when entering/leaving an activity:
-
#!/bin/sh
+
<source lang="bash">
-
+
#!/bin/sh
-
if [ "$1" = "start" ] ; then
+
 
-
  # Commands to connect to the internet
+
if [ "$1" = "start" ] ; then
-
elif [ "$1" = "stop" ] ; then
+
  # Commands to connect to the internet
-
  # Commands to disconnect from the internet
+
elif [ "$1" = "stop" ] ; then
-
fi
+
  # Commands to disconnect from the internet
 +
fi
 +
</source>
 +
 
 +
Putting the above in <code>/home/user/.activities/scripts/internet</code> and having an activity named "internet" (watch for the case) will result in auto connecting/disconnecting to/from the Internet when entering/leaving that activity.
 +
 
 +
For desktop widgets that want to implement per-activity settings and are not already handled by actman it is possible to put a script in <code>/home/user/.activities/scripts/always</code> like this:
 +
 
 +
<source lang="bash">
 +
#!/bin/sh
-
Putting the above in /home/user/.activities/scripts/internet and having an activity named "internet" (watch for the case) will result in auto connecting/disconnecting to/from the Internet when entering/leaving that activity.
+
# This is where actman stores the settings of the activities
 +
# ACTMAN_ACTIVITY contains the name of the corresponding activity and it is
 +
# set by actman
 +
DEST=/home/user/.activities/$ACTMAN_ACTIVITY
-
For desktop widgets that want to implement per-activity settings and are not already handled by actman it is possible to put a script in /home/user/.activities/scripts/always like this:
+
if [ "$1" = "start" ] ; then
 +
  OLDSETTINGS="$DEST/myapp.tar"
 +
  if [ -e "$OLDSETTINGS" ] ; then
 +
    ( cd /home/user
 +
      rm -rf .mywidget
 +
      mkdir .mywidget
 +
      tar -xf $OLDSETTINGS )
 +
  fi
 +
elif [ "$1" = "stop" ] ; then
 +
  ( cd /home/user;
 +
    tar -cf $DEST/myapp.tar .mywidget
 +
    rm -rf .mywidget
 +
  )
 +
fi
 +
</source>
-
#!/bin/sh
+
The idea is to store the configuration files in the same location where actman stores each activity's settings (<code>/home/user/.activities/<activity name>/</code>) as a tar (or even better as a tgz). <code>$ACTMAN_ACTIVITY</code> will always have the name of the current activity and can be used as such.
-
+
-
# This is where actman stores the settings of the activities
+
-
# ACTMAN_ACTIVITY contains the name of the corresponding activity and it is
+
-
# set by actman
+
-
DEST=/home/user/.activities/$ACTMAN_ACTIVITY
+
-
+
-
if [ "$1" = "start" ] ; then
+
-
  OLDSETTINGS="$DEST/myapp.tar
+
-
  if [ -e "$OLDSETTINGS" ] ; then
+
-
    ( cd /home/user
+
-
      rm -rf .mywidget
+
-
      mkdir .mywidget
+
-
      tar -xf $OLDSETTINGS )
+
-
  fi
+
-
elif [ "$1" = "stop" ] ; then
+
-
  ( cd /home/user;
+
-
    tar -cf $DEST/myapp.tar .mywidget
+
-
    rm -rf .mywidget
+
-
  )
+
-
fi
+
-
The idea is to store the configuration files in the same location where actman stores each activity's settings (/home/user/.activities/<activity name/) as a tar (or even better as a tgz). $ACTMAN_ACTIVITY will always have the name of the current activity and can be used as such.
+
[[Category:Software]]

Revision as of 10:44, 17 January 2011

Desktop Activity Manager, or D-A-M, or DAM, or actman, is a command line tool and a status menu widget that allows saving and restoring of the destkop. There can be multiple saved desktops so it is possible to have different activities (desktop profiles) and switch between them by saving the current one and loading another.

For discussion about actman visit this thread.

Contents

Status menu widget

The status menu widget is a front-end to the command line tool. While it doesn't have all its features it is easier to use and handles all common user actions.

Screenshot of Actman main page
Main page

The main page includes the following actions:

  • Select: Saves the current activity and switches to the selected (highlighted) activity.
  • New: Create a new activity that is a duplicate of the current one
  • Rename: Renames the selected activity
  • Delete: Deletes the selected activity. It is not possible to delete the current activity
  • More: Shows more actions


Screenshot of Actman more actions
More actions

When clicking "more", some more actions are shown:

  • Store current: Saves the current activity without switching to a new one
  • Reload current: Reloads the current activity

Command line tool

The command line tool is named "activity" and is installed in /usr/bin. It should be run as user (and not as root!) and it includes a help screen:

~ $ /usr/bin/activity help  
Activity manager 1.1

Available commands:

  change DEST		Store current activity and load DEST.
  clone ACT1 ACT2	Create activity ACT2 as a clone of ACT1. Current
  			activity will not be changed.
  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.
  load [-f] SRC		Load activity SRC. If -f is used then it will be
  			allowed to re-load the current activity.
  new ACTIVITY		Same as create.
  reload		Reload current activity without storing first.
  remove [-f] ACTIVITY	Remove activity ACTIVITY. If -f is used then there
  			will be no questions asked.
  rename ACT1 ACT2	Rename activity ACT1 to ACT2.
  runstart [ACTIVITY]	Run scripts of entering an activity
  runend [ACTIVITY]	Run scripts of ending an activity
  store DEST		Store current activity as DEST.
  version		Print the version

Activities are stored under /home/user/.activities

To get a list of available activities use "list":

~ $ /usr/bin/activity list 
car
clean
empty
main
main2
main3
Tei
Test
test2

To save the current activity and switch to a new one use "change", etc.

How it works

TBD

Running user scripts

Since versions 1.1, actman has the ability to run user scripts.

The scripts are stored under /home/user/.activities/scripts (which does not exist by default).

There are two kind of scripts:

  • Scripts that are associated with an activity (kindA)
  • Scripts that are not associated with an activity (kindB)

There are two kind of script invocations "start" and "stop":

  • start: is used when entering the corresponding activity
  • end: is used when leaving the corresponding activity

The rationale behind this is to have initscript-like scripts that may start or stop services (kindA) or save/restore a widget's configuration (kindB).

Scripts associated with an activity

Those scripts are installed in a directory named as the activity. For example, for the activity 'main' one can place scripts in /home/user/.activities/scripts/main. They will be ran when switching to or from that activity.

Scripts not associated with an activity

They are installed in /home/user/.activities/scripts/always and are ran whenever an activity is switched.

Invocation

Scripts are ran with the parameter "start" or "stop" depending on the invocation type. For example it is possible to create a script that connects/disconnects from the Internet when entering/leaving an activity:

#!/bin/sh
 
if [ "$1" = "start" ] ; then
  # Commands to connect to the internet
elif [ "$1" = "stop" ] ; then
  # Commands to disconnect from the internet
fi

Putting the above in /home/user/.activities/scripts/internet and having an activity named "internet" (watch for the case) will result in auto connecting/disconnecting to/from the Internet when entering/leaving that activity.

For desktop widgets that want to implement per-activity settings and are not already handled by actman it is possible to put a script in /home/user/.activities/scripts/always like this:

#!/bin/sh
 
# This is where actman stores the settings of the activities
# ACTMAN_ACTIVITY contains the name of the corresponding activity and it is
# set by actman
DEST=/home/user/.activities/$ACTMAN_ACTIVITY
 
if [ "$1" = "start" ] ; then
  OLDSETTINGS="$DEST/myapp.tar"
  if [ -e "$OLDSETTINGS" ] ; then
    ( cd /home/user
      rm -rf .mywidget
      mkdir .mywidget
      tar -xf $OLDSETTINGS )
  fi
elif [ "$1" = "stop" ] ; then
  ( cd /home/user;
    tar -cf $DEST/myapp.tar .mywidget
    rm -rf .mywidget
  )
fi

The idea is to store the configuration files in the same location where actman stores each activity's settings (/home/user/.activities/<activity name>/) as a tar (or even better as a tgz). $ACTMAN_ACTIVITY will always have the name of the current activity and can be used as such.