Skip to content

Latest commit

 

History

History
216 lines (153 loc) · 6.67 KB

hooks.rst

File metadata and controls

216 lines (153 loc) · 6.67 KB

Hooks

Hooks are python callables that live in a module specified by hooksfile in the config. Per default this points to ~/.config/alot/hooks.py.

Pre/Post Command Hooks

For every COMMAND <usage.commands> in mode MODE <modes>, the callables pre_MODE_COMMAND and post_MODE_COMMAND -- if defined -- will be called before and after the command is applied respectively. In addition callables pre_global_COMMAND and post_global_COMMAND can be used. They will be called if no specific hook function for a mode is defined. The signature for the pre-send hook in envelope mode for example looks like this:

Consider this pre-hook for the exit command, that logs a personalized goodbye message:

import logging
from alot.settings.const import settings
def pre_global_exit(**kwargs):
    accounts = settings.get_accounts()
    if accounts:
        logging.info('goodbye, %s!' % accounts[0].realname)
    else:
        logging.info('goodbye!')

Other Hooks

Apart from command pre- and posthooks, the following hooks will be interpreted: