Extension modules for LibFM

From LXDE.org
Jump to: navigation, search

The LibFM since version 1.2.0 allow you add own extensions (A.K.A. plugins or modules) to add features into applications that use it such as PCManFM or LXPanel.

You can disable or enable some modules using LibFM configuration options modules_blacklist and modules_whitelist. First one contains list of masks of modules that are disallowed to load. Second one contains list of exceptions from the blacklist. Items in list are delimited with semicolon (;) and each item contains mask "module-type:module-key". Mask may contain wildcard "*". If you want to use "*" as literal you should escape it with backslash (\).

How to create a plugin

Creating the module is simple. Example of module for PCManFM that adds link target info to statusbar:

#include <pcmanfm-modules.h>
#include <string.h>

FM_DEFINE_MODULE(tab_page_status, symlink)

static char *_sel_message(FmFileInfoList *files, gint n_files)
{
  FmFileInfo *fi = fm_file_info_list_peek_head(files);
  if (n_files > 1 || !fm_file_info_is_symlink(fi))
    return NULL;
  return g_strdup_printf("=> %s", fm_file_info_get_target(fi));
}

FmTabPageStatusInit fm_module_init_tab_page_status = {
  NULL,
  NULL,
  _sel_message
};

You can compile it the same way as any other application that uses GLib but do shared module compilation, for example:

gcc -o tab-page-symlink.so -Wall -shared -fPIC -Wl,-z,defs tab-page-symlink.c `pkg-config --cflags --libs libfm`

then install into appropriate directory and it will work for you after application restart.

Types of plugins supported by LibFM

Modules are installed into $(libdir)/libfm/modules

Module type Module purpose
vfs VFS implementation for some URI scheme

Types of plugins supported by LibFM-GTK

Modules are installed into $(libdir)/libfm/modules

Module type Module purpose
gtk_menu_scheme folder and selection context menu extension for some URI scheme
gtk_menu_mime selection context menu extension for some MIME type
gtk_file_prop file properties dialog extension for some MIME type
gtk_folder_col implementation of custom folder view column

Types of plugins supported by PCManFM

Modules are installed into $(libdir)/pcmanfm

Module type Module purpose
tab_page_status allows adding some text into main window status bar

Types of plugins supported by LXPanel

Modules are installed into $(libdir)/lxpanel/plugins

Module type Module purpose
lxpanel_gtk plugin for the panel

Types of plugins supported by LXHotkey

Modules are installed into $(libdir)/lxhotkey

Module type Module purpose
lxhotkey plugin to handle some window manager configuration
lxhotkey_gui plugin representing some GUI frontend

Modules supplied with LibFM and LibFM-GTK

Module type:key Module purpose
vfs:menu VFS for access to the Desktop Menu via menu://applications/ URI
vfs:search VFS for the file system search via search:// URI
gtk_menu_scheme:* support for DES-EMA user-defined options in the context menu
gtk_menu_scheme:trash update context menu for trash:// URIs
gtk_file_prop:application/x-desktop allows editing properties of Desktop Entry File in the file properties dialog
gtk_file_prop:inode/x-shortcut allows editing properties of some shortcut to URI in the file properties dialog

Known third-party plugins

Module type:key Module original name Module purpose
tab_page_status:image_size pcmanfm-image-size-module show image sizes in the statusbar
gtk_folder_col:taglib_album, gtk_folder_col:taglib_artist, ... gtk-column-taglib-title, ... show informations about music files (obtained with taglib) in additional columns
gtk_folder_col:group gtk-column-group show the group ownership of files and directories in an additional column
lxpanel_gtk:topmenu_lxpanel topmenu-gtk a panel applet for a global menubar (like one in OS X)