Documentation
¶
Overview ¶
Package histfile reads and changes the history file that notifyd keeps of what this desktop received, for the daemon and the history window alike.
Index ¶
- Constants
- func Clear(path string) error
- func Delete(path string, now time.Time, ids ...string) (int, error)
- func Invisible(r rune) bool
- func Path() (string, error)
- func Printable(s string, multiline bool) string
- func WithLock(path string, fn func() error) error
- func Write(path string, entries []Entry) error
- func WriteFileAtomic(path string, data []byte, pattern string) error
- type Entry
- type Reply
Constants ¶
const ( MaxEntries = 500 MaxAge = 30 * 24 * time.Hour )
The history keeps at most MaxEntries, none older than MaxAge. The server keeps no content, so this is the only copy.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
Delete removes the entries with the given IDs and reports how many it found. Like a compaction, it also drops what Read would not return. Callers hold the lock.
func Path ¶
Path is $NOTIFYD_HISTORY, or notifyd-history.jsonl in $XDG_STATE_HOME/notifier (default ~/.local/state/notifier).
func Printable ¶
Printable replaces control and format characters (terminal escapes, bidi overrides, zero-width characters) with U+FFFD, keeping tabs, and newlines only when multiline. Senders choose the text.
func WithLock ¶
WithLock runs fn holding an exclusive lock shared by every process that changes the history: the running daemon appends while `notifyd history clear`, pair, unpair, or the history window may run in another. The lock file stays; removing it would let two processes hold different locks.
Types ¶
type Entry ¶
type Entry struct {
ID string `json:"id"`
Title string `json:"title"`
Body string `json:"body,omitempty"`
Priority string `json:"priority"`
SentAt int64 `json:"sent_at"`
ReceivedAt int64 `json:"received_at"`
Channel string `json:"channel,omitempty"`
ChannelID string `json:"channel_id,omitempty"`
Reply *Reply `json:"reply,omitempty"`
}
Entry is one received message. Times are Unix seconds.
func Read ¶
Read returns the entries at path, newest first: each message once (as first received), none older than MaxAge, at most MaxEntries. Lines it cannot parse are skipped. A missing file is an empty history.
func (Entry) OnDefaultChannel ¶
OnDefaultChannel reports whether e went to the user's default channel, which clients leave unnamed.