FastX 3.1 Event Scripts

If a FastX session is started with a profile that has “Event Scripts” specified, those scripts will be run as the same user who is running the session. The various events are triggered when the following events happen:

'start': Triggered soon after the session starts.
'connect': Triggered when a connection is made to the session. [To be slightly modified when we implement sharing.]
'disconnect': Triggered when the connection to the session is disconnected.
'params': Triggered when the params of a session (such as the name) are changed.
'terminate': Triggered when a session is terminated.

With the exception of ‘terminate’, the scripts that are triggered run in the background. This means that if the script is long-running, it the session may terminate while the script is still running. In the case of ‘terminate’, the session monitor will not exit, and the thus the session directory will not be removed, until the terminate script exits.

If the script specified is a single line (after removing blank lines at the start and end), it will be run under the shell. This means that special characters, such as file pattern matching, environment variable expansion, and file redirection, will all work.

If the script is multiple lines, then the entire script is put into a script file, which is executed when the trigger happens. This means that any multiple line event script should start with an interpreter, e.g. !/bin/bash.

The following environment variables will be set for an event script:

$DISPLAY, $XAUTHORITY, $FASTX_SESSION_ID, $FASTX_SESSION_DIR, as well as the usual ones (HOME, USER, etc.)

This means that the event script could run an X11 application, such as xmessage or xwininfo.


Example:

Here is a ‘terminate’ script that will kill any background processes started from a session:

kill $(ps ewwx | grep DISPLAY=$DISPLAY | awk '{print $1}')