Session Scripts

Enlightenment can now automatically run user scripts or applications during Startup, Restart, and Shutdown. This facilitates the loading of system tray applets, rss readers, screensavers, and other daemons (e.g. dbus), and allows for cleanup of programs that don't terminate properly when E quits (this is especially common with KDE applications in E and the arts daemon or dcop server keeps running).

Enlightenment accomplishes this with the addition of two new keys in the $ECONFDIR/e_config--#.#.cfg (#.# may vary depending on your X setup -- for most people, it will be 0.0). These are:

	misc.session.enable_script 
	misc.session.script 
      

misc.session.enable_script is a boolean. When set to 1, Enlightenment will execute the script in the misc.session.script key. By default, this feature is disabled. When enabled, it will do nothing until the user configures his/her home directory ($ECONFDIR -- normally ~/.e16).

The default session.script is located in $EROOT/scripts/session.sh ($EROOT is normally /usr/share/e16 or /usr/local/share/e16). It will look for directories in the user's $ECONFDIR/ (~/.e16/) called:

	~/.e16/ ($ECONFDIR)
	        Init/
	        Start/
	        Stop/
      

and run any and/or all scripts or executables in each when E starts, restarts, and shuts down. If no scripts or executables are present, or if any of the directories Init, Start, and Stop do not exist, NOTHING will happen and E will start up as usual. So, in order to use session scripts, all the user has to do is to populate the Init, Start, and Stop directories with scripts, applications, or links to applications that should run during Startup, Restart, or when E is stopped.

The default values for the new keys are:

	misc.session.enable_script = 0
	misc.session.script = $EROOT/scripts/session.sh
      

The user may write a custom script and place it anywhere. Simply modify the config file by using:

	$ eesh set misc.session.script myscript
      

and modify it (be sure to chmod +x the file otherwise it won't run). The session script is called with one of three command parameters; init, start, and stop. Any custom script should have a code block similar to this in order to function properly in Enlightenment.

	case "$1" in
	init)
                # do blah
                # or do function init
	start)
                # do blah
                # of do function start
	stop)
                # do blah
                # or do function stop
	esac
      

Automatic script running can be enabled/disabled via the Session Settings dialog in Enlightenment and checking/unchecking the option Enable Session Script, by editing the user cfg file and setting the misc.session.enable_script key to 1/0, or with

	$ eesh set misc.session.enable_script 1/0
      

This process is very flexible since when used, the user can turn off individual scripts and applications by chmod -x or simply leave the startup directories empty or remove them.