September 8, 2016 - Mike Blumenkrantz

How to Create an Enlightenment Module

This article is part of a series of tutorials about Enlightenment: a compositing and stacking window manager.

Module writing is one of the primary ways to expand the functionality of Enlightenment. By dynamically loading modules, the compositor is able to import code that has access to most Enlightenment internals. This allows developers to modify the desktop environment in nearly any way they can imagine, from new gadgets to compositor effects. This article will take a look at the basics of creating an Enlightenment module.

The first part of creating a module is setting up a .desktop file for it. This allows the module to be visible for users within the module configuration dialog. An example file looks something like this:

The ‘Name’ is the user-visible name of your module, and the ‘Icon’ is the filename of the .edj file which accompanies the module. The ‘Comment’ field provides supplementary information to the user that describes the functionality of the module. ‘Category’ is the category under which the module will be listed in the module configuration. With all of these fields provided the module will be displayed to the user with all possible information available.

Next up are the required hooks in the module code. These are namespaced symbols the compositor looks for when attempting to load a module. The first such symbol is the module API declaration:

The version here is used to ensure that the module has been compiled against a compatible version of Enlightenment; older modules will be prevented from loading to avoid crashes and other unintended behaviors resulting from ABI breakages. The second member of the struct is the module’s name.

Additionally, there are three function hooks which a module provides. The first one, the init function, is mandatory:

This function runs the necessary setup calls for the module, returning a non-null value that will be attached to the module object as its data pointer. If this function returns null, the module is considered to have failed to load and appropriate error messages will be displayed automatically to the user.

Modules also have access to a special function for saving data:

This function is optional. When provided, it’s called whenever Enlightenment saves its configuration so that the module may also save its own configuration. The code for this function could be as simple as:

This function returns 1 for success and 0 for failure, though the value is never checked.

Lastly, modules are able to have an optional shutdown function that is called whenever the module is unloaded:

If this exists, it will trigger just prior to removing the module from configuration. This function can be used to clean up any persisting data structures or objects and it returns 1 on success and 0 on failure, but this value is never used.

That concludes the basics of Enlightenment module development. For some examples of existing module code, check out the repository category on git!

Mike Blumenkrantz

About Mike Blumenkrantz

Mike is the release manager for Enlightenment as well as a core developer of the EFL toolkit. He sometimes contributes to the Servo application embedding API/ABI, and in his free time he attempts to write desktop applications.

Image Credits: EFL Project

Development / EFL Compositing / enlightenment /

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments Protected by WP-SpamShield Anti-Spam