mail

package
v0.3.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mail is the unread-mail service, the Go counterpart of crates/wayle-shell-core's services/mail: 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

View Source
const Debounce = 500 * time.Millisecond

Debounce coalesces a maildir-sync burst into one re-query.

View Source
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

type AccountUnread struct {
	Name  string
	Icon  string
	Count uint32
}

AccountUnread is one account's resolved icon and unread count.

type CLI

type CLI struct{}

CLI runs the notmuch binary, as the Rust service does.

func (CLI) Count

func (CLI) Count(ctx context.Context, query string) uint32

Count is `notmuch count <query>`, 0 on any failure (query_count).

func (CLI) DatabasePath

func (CLI) DatabasePath(ctx context.Context) (string, bool)

DatabasePath is `notmuch config get database.path` (maildir_path).

func (CLI) Newest

func (CLI) Newest(ctx context.Context, query string, limit int) []Message

Newest is `notmuch search --format=json --sort=newest-first --limit=N <query>`, one (sender, subject) per thread, empty on any failure (query_new_messages).

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 Message

type Message struct {
	Sender  string
	Subject string
}

Message is one newest-first search hit.

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>`, 0 on any failure.
	Count(ctx context.Context, query string) uint32
	// Newest returns up to limit newest matches, empty on failure.
	Newest(ctx context.Context, query string, limit int) []Message
	// 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) Run

func (s *Service) Run(ctx context.Context)

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, as in the Rust service. The watch is armed before the seed query so a change during it is not lost.

func (*Service) State

func (s *Service) State() State

State returns the latest counts.

func (*Service) Subscribe

func (s *Service) Subscribe() (<-chan struct{}, func())

Subscribe ticks after every publish; stop unregisters.

type State

type State struct {
	Accounts []AccountUnread
	Total    uint32
}

State is one published read: the per-account counts in config order (empty without accounts) and the total.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL