Watch for envelopes changes

$ himalaya envelope watch [OPTIONS] [FOLDER]

Watches the given folder (defaults to INBOX) and executes hooks when changes occur on envelopes.

If synchronization is enabled, the command will watch local cached folders. To force the command to watch remote folders, you can either:

  1. Force the remote backend for the watch envelopes feature, for example:

    envelope.watch.backend = "imap"
    
  2. Disable the cache with the --disable-cache flag:

    $ himalaya envelope watch --disable-cache
    

Options

-f|--folder

The name of the folder. Defaults to INBOX.

--disable-cache

Disable any sort of cache.

The action depends on commands it apply on. For example, when listing envelopes using the IMAP backend, this flag will ensure that envelopes are fetched from the IMAP server rather than the synchronized local Maildir.

-a|--account

Override the default account.

An account name corresponds to an entry in the table at the root level of your TOML configuration file.

Settings

envelope.watch.{event}.{hook}

Configure the hook to execute when receiving a specific watch event.

Possible values of event:

  • envelope.watch.received.{hook}: trigger the hook when receiving a new envelope

  • envelope.watch.any.{hook}: trigger the hook for any other event

Possible values of hook:

  • envelope.watch.{event}.cmd: trigger the given shell command

  • envelope.watch.{event}.notify: send a system notification

    • envelope.watch.{event}.notify.summary: customize the summary (title) of the notification

    • envelope.watch.{event}.notify.body: customize the body (content) of the notification

    Both summary and body accept placeholders that will be replaced at runtime:

    • {id}: the envelope id

    • {subject}: the envelope subject

    • {sender}: the sender name or his email address

    • {sender.name}: the sender name or unknown

    • {sender.address}: the sender email address

    • {recipient}: the recipient name or his email address

    • {recipient.name}: the recipient name or unknown

    • {recipient.address}: the recipient email address

envelope.watch.received.notify.summary = "📬 New message from {sender}"
envelope.watch.received.notify.body = "{subject}"

envelope.watch.any.cmd = "mbsync -a"

Note: it is possible to cumulate hooks for a same event. For example it is possible to send a system notification and execute a command when receiving a new envelope.