Documentation
¶
Overview ¶
Package mail is the unread-mail service: notmuch queries (one per account, or the single query), re-run when the notmuch maildir changes, with optional desktop notifications for newly-arrived messages. The bar module and the dropdown both read one Service.
Index ¶
Constants ¶
const Debounce = 500 * time.Millisecond
Debounce coalesces a maildir-sync burst into one re-query.
const NotifyMax = 5
NotifyMax caps how many per-message notifications one arrival burst fires, so a large sync cannot flood the notification daemon.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountUnread ¶
AccountUnread is one account's resolved icon and unread count; Err is why the count could not be read, and Count is then 0.
type CLI ¶
type CLI struct{}
CLI runs the notmuch binary.
func (CLI) DatabasePath ¶
DatabasePath is `notmuch config get database.path` (maildir_path).
type DesktopNotifier ¶
type DesktopNotifier struct {
Sender *desktopnotify.Sender
}
DesktopNotifier fires mail notifications as "lys-shell" through the session notification daemon.
func (DesktopNotifier) Notify ¶
func (d DesktopNotifier) Notify(summary, body, icon string)
Notify sends in the background; failures are logged, never returned, as a missing notification must not fail the re-query.
type Notifier ¶
type Notifier interface {
Notify(summary, body, icon string)
}
Notifier fires one desktop notification, fire-and-forget.
type Notmuch ¶
type Notmuch interface {
// Count is `notmuch count <query>`.
Count(ctx context.Context, query string) (uint32, error)
// Newest returns up to limit newest matches.
Newest(ctx context.Context, query string, limit int) ([]Message, error)
// DatabasePath is `notmuch config get database.path`; ok=false
// when there is no database to watch.
DatabasePath(ctx context.Context) (string, bool)
}
Notmuch is the query seam.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service holds the counts and runs the watch loop.
func New ¶
func New(cfg config.MailConfig, notmuch Notmuch, notifier Notifier) *Service
New builds a service; Run starts it. A nil notifier disables notifications regardless of the notify key.
func (*Service) PerAccount ¶
PerAccount reports whether the accounts are counted, rather than the single query.
func (*Service) Run ¶
Run seeds the counts without notifying (existing unread mail at startup is not "new"), then re-queries after each settled burst of maildir changes until ctx ends. Without a notmuch database the seed is all there is. The watch is armed before the seed query so a change during it is not lost.
type State ¶
type State struct {
Accounts []AccountUnread
Total uint32
Err error
}
State is one published read: the per-account counts in config order (empty without accounts), the total of the counts that were read, and Err, every query that failed, nil when all were read.