Documentation
¶
Overview ¶
Package tray is bentoo-tray's event loop and its notification and icon policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAlreadyRunning is returned by Run when another process owns the // session bus name. ErrAlreadyRunning = errors.New("another bentoo-tray instance owns the session bus name") // ErrBusLost is returned by Run when the session bus connection is lost // while running. ErrBusLost = errors.New("the session bus connection was lost") )
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is bentoo-tray's event loop. All of its fields belong to the goroutine running Run. The only other goroutines it starts are the URL openings, which report back over a channel, and the bounded release of the bus name at a stop; neither touches a field.
func (*App) Run ¶
Run owns the bus name, loads the state, starts the icon and runs the loop until ctx is done, the user quits or the bus is lost. A stop saves the state and releases the name, returning nil; a lost bus saves and returns ErrBusLost; another owner of the name is ErrAlreadyRunning. Any other error is a startup failure.
type BusOwner ¶
type BusOwner interface {
Acquire(ctx context.Context) (acquired bool, err error)
Release() error
Lost() <-chan struct{}
}
BusOwner owns the session bus name; *dbusx.Owner implements it.
type Clock ¶
Clock is the App's source of time. After is used for every schedule, so a test can drive the loop with a manual clock.
type Deps ¶
type Deps struct {
Log *slog.Logger
Clock Clock
Rand func() float64
Config config.TrayConfig
Feed FeedFetcher
News NewsReader
Pkgs InstalledReader
Notify Notifier
Icon TrayIcon
Open Opener
Net NetworkMonitor
Store StateStore
Bus BusOwner
}
Deps is everything the App talks to. Feed is nil when the feed URL was refused: the App then runs on the offline news alone. A nil Log discards, a nil Clock is the SystemClock, a nil Rand is math/rand/v2's Float64 and a nil Net behaves as netmon.Absent(); every other field is required.
type FeedFetcher ¶
FeedFetcher fetches the notices feed; *feed.Fetcher implements it.
type InstalledReader ¶
type InstalledReader interface {
Installed(ctx context.Context) (pkgs []pkgdb.Package, skipped int, err error)
}
InstalledReader lists the installed packages; pkgdb.Reader implements it.
type NetworkMonitor ¶
type NetworkMonitor interface {
Allowed(ctx context.Context) (netmon.Verdict, error)
Changed() <-chan struct{}
}
NetworkMonitor reports NetworkManager's view of the network; *netmon.Monitor implements it.
type NewsReader ¶
type NewsReader interface {
Unread(ctx context.Context) ([]notices.Notice, error)
Changed() <-chan struct{}
}
NewsReader reads the bentoo repository's unread news; *news.Reader implements it. Items returned together with an error are a partial result. Changed fires when the unread list changed.
type Notifier ¶
type Notifier interface {
Send(ctx context.Context, m notify.Message) (uint32, error)
Events() <-chan notify.Event
}
Notifier sends desktop notifications and reports the actions taken on them; *notify.Notifier implements it.
type StateStore ¶
StateStore loads and saves the state file; *state.Store implements it.
type SystemClock ¶
type SystemClock struct {
Done <-chan struct{}
}
SystemClock is the wall clock. Its timers keep wall-clock deadlines: Go's runtime timers count CLOCK_MONOTONIC, which stops while the machine is suspended, so a plain time.After(d) armed at 22:00 for "until 08:00" would fire hours late after a night in suspend. A SystemClock timer fires at most wallPoll after its wall-clock deadline, suspend or not.
Each pending timer is a goroutine that exits when it fires or when Done is closed; a nil Done keeps abandoned timers alive until their deadline.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package feed fetches the bentoo notices feed over HTTPS with ETag revalidation, a body size cap and a request deadline.
|
Package feed fetches the bentoo notices feed over HTTPS with ETag revalidation, a body size cap and a request deadline. |
|
Package icons holds the tray icon as SNI pixmaps.
|
Package icons holds the tray icon as SNI pixmaps. |
|
Package messages is bentoo-tray's message catalog: every menu label, notification text and summary format the tray shows, in English, in one place.
|
Package messages is bentoo-tray's message catalog: every menu label, notification text and summary format the tray shows, in English, in one place. |
|
Package schedule holds the pure timing functions of bentoo-tray: the startup delay, the jittered check interval and the failure backoff.
|
Package schedule holds the pure timing functions of bentoo-tray: the startup delay, the jittered check interval and the failure backoff. |
|
Package state persists bentoo-tray's state: the feed ETag and serial, the read state and source of every notice, the pause end, the backoff and the earliest next fetch.
|
Package state persists bentoo-tray's state: the feed ETag and serial, the read state and source of every notice, the pause end, the backoff and the earliest next fetch. |
|
Package version is bentoo-tray's own version, independent of the bentoolkit release it ships in.
|
Package version is bentoo-tray's own version, independent of the bentoolkit release it ships in. |