Getting Started
Plugins
- List of plugins
- Installing plugins
- Writing plugins
- Architecture
- Sharing plugins
- Core plugin
- Caveats
- API
Configuration
Plugin Architecture
On the
previous page, we
defined a new command in a Python (.py
) file:
from fman import DirectoryPaneCommand, show_alert class SayHi(DirectoryPaneCommand): def __call__(self): show_alert('Hello World!')
A DirectoryPaneCommand
is an action that can be performed in
the context of a directory pane:
We also bound our command to a keyboard shortcut:
[ { "keys": ["F3"], "command": "say_hi" } ]
Note how the command was called SayHi
in the Python file, but
is referred to in the settings file as say_hi
. When fman
encounters a command called ThisIsAnExample
in a Python file,
it registers it as this_is_an_example
.
Directory structure
The directory structure of a typical plugin looks as follows:
-
My Plugin/
-
my_plugin/
__init__.py
some_module.py
some_other_module.py
- ...
Key Bindings.json
my_plugin
is a Python package, that is, a directory
containing a file called __init__.py
and possibly other
.py
files. All your Python sources must lie inside such a
package. The name of your package must be unique to avoid name clashes
with other plugins.
(Please note that fman's Reload Plugins command currently only
reloads __init__.py
. This is a
bug.)
Plugin order
fman loads plugins in the following order:
- Shipped Plugins. These plugins are included in fman's installation directory. Currently, Core is the only such plugin.
-
Third-party Plugins. These lie in the
Plugins/Third-party/
subdirectory of your data directory. Plugins installed with fman's built-in commands get placed here. -
User Plugins. Plugins you develop yourself should be
placed in the
Plugins/User/
folder of the data directory. A special case is the Settings plugin, described below. - The Settings Plugin. This is a normal User plugin except for the special property that it is the last plugin that is loaded. Because of this, it can overwrite the settings of all other plugins. You use it to configure fman; For instance when defining your own keyboard shortcuts.
Each plugin overwrites or extends the settings of any previously loaded
plugins. For example, the
Core plugin contains the
settings file
Key Bindings.json
. On the
previous page, we
created a file with the same name in our Hello World
plugin.
Our file thus extended the existing keyboard shortcuts by a new one.