Documentation ¶
Overview ¶
Package notifier contains common data structures for notifications.
Index ¶
- Constants
- Variables
- func Columns(w io.Writer, write func(io.Writer))
- func Dial(ctx context.Context) (context.Context, *jrpc2.Client, error)
- func LoadConfig(path string, cfg *Config) error
- func PluginAssigner(cfg *Config) jrpc2.Assigner
- func PromptForText(ctx context.Context, req *TextRequest) (string, error)
- func RegisterFlags()
- func RegisterPlugin(name string, p Plugin)
- func SetSystemClipboard(ctx context.Context, data []byte) error
- type ClipClearRequest
- type ClipGetRequest
- type ClipSetRequest
- type Config
- type EditRequest
- type Plugin
- type PostRequest
- type SayRequest
- type TextRequest
Constants ¶
const UserCancelled = jrpc2.Code(-29999)
UserCancelled is the code returned when a user cancels a text request.
Variables ¶
var ErrNotApplicable = errors.New("plugin is not applicable")
ErrNotApplicable is returned by a plugin's Init function if the plugin cannot be used with the given configuration.
var ResourceNotFound = jrpc2.Code(-29998)
ResourceNotFound is returned when a requested resource is not found.
Functions ¶
func Columns ¶
Columns calls write with a tabwriter directed to w, and flushes its output when write returns.
func Dial ¶
Dial connects to the flag-selected JSON-RPC server and returns a context and a client ready for use. The caller is responsible for closing the client.
func LoadConfig ¶
LoadConfig loads a configuration from the file at path into *cfg.
func PluginAssigner ¶
PluginAssigner returns a jrpc2.Assigner that exports the methods of all the registered plugins.
func PromptForText ¶
func PromptForText(ctx context.Context, req *TextRequest) (string, error)
PromptForText requests a string of text from the user.
func RegisterFlags ¶
func RegisterFlags()
RegisterFlags installs a standard -server flag in the default flagset. This function should be called during init in a client main package.
func RegisterPlugin ¶
RegisterPlugin registers a plugin. This function will panic if the same name is registered multiple times.
Types ¶
type ClipClearRequest ¶
type ClipClearRequest struct {
Tag string `json:"tag,omitempty"` // the tag to clear or remove
}
A ClipClearRequest is sent to clear the contents of the clipboard.
func (ClipClearRequest) DisallowUnknownFields ¶
func (ClipClearRequest) DisallowUnknownFields()
type ClipGetRequest ¶
type ClipGetRequest struct { Tag string `json:"tag,omitempty"` // the tag to assign the data Save string `json:"save,omitempty"` // save active clip to this tag Activate bool `json:"activate,omitempty"` // make this clip active }
A ClipGetRequest is sent to query the contents of the clipboard.
func (ClipGetRequest) DisallowUnknownFields ¶
func (ClipGetRequest) DisallowUnknownFields()
type ClipSetRequest ¶
type ClipSetRequest struct { Data []byte `json:"data"` // the data to be stored Tag string `json:"tag,omitempty"` // the tag to assign the data Save string `json:"save,omitempty"` // save active clip to this tag AllowEmpty bool `json:"allowEmpty"` // allow data to be empty }
A ClipSetRequest is sent to update the contents of the clipboard.
func (ClipSetRequest) DisallowUnknownFields ¶
func (ClipSetRequest) DisallowUnknownFields()
type Config ¶
type Config struct { Address string DebugLog bool `yaml:"debugLog"` // Settings for the clipboard service. Clip struct { SaveFile string `yaml:"saveFile"` } // Settings for the editor service. Edit struct { Command string TouchNew bool `yaml:"touchNew"` } // Settings for the notification service. Notify struct { Sound string Voice string } }
Config stores settings for the various notifier services.
type EditRequest ¶
type EditRequest struct { // The base name of the file to edit. Name string `json:"name,omitempty"` // The current contents of the file. Content []byte `json:"content,omitempty"` }
An EditRequest is a request to edit the contents of a file.
func (EditRequest) DisallowUnknownFields ¶
func (EditRequest) DisallowUnknownFields()
type Plugin ¶
type Plugin interface { // Init is called once before any other methods of the plugin are used, with // a pointer to the shared configuration. Init(*Config) error // Update may be called periodically to give the plugin an opportunity to // update its state. Update() error // Assigner returns an assigner for handlers. Assigner() handler.Map }
A Plugin exposes a set of methods.
type PostRequest ¶
type PostRequest struct { Title string `json:"title,omitempty"` Subtitle string `json:"subtitle,omitempty"` Body string `json:"body,omitempty"` Audible bool `json:"audible,omitempty"` After time.Duration `json:"after,omitempty"` }
A PostRequest is a request to post a notification to the user.
func (PostRequest) DisallowUnknownFields ¶
func (PostRequest) DisallowUnknownFields()
type SayRequest ¶
type SayRequest struct { Text string `json:"text"` Voice string `json:"voice,omitempty"` After time.Duration `json:"after,omitempty"` }
A SayRequest is a request to speak a notification to the user.
func (SayRequest) DisallowUnknownFields ¶
func (SayRequest) DisallowUnknownFields()
type TextRequest ¶
type TextRequest struct { Prompt string `json:"prompt,omitempty"` Default string `json:"default,omitempty"` Hide bool `json:"hide,omitempty"` }
A TextRequest is a request to read a string from the user.
func (TextRequest) DisallowUnknownFields ¶
func (TextRequest) DisallowUnknownFields()
Directories ¶
Path | Synopsis |
---|---|
Program clipset sends a clipboard set request to a noteserver.
|
Program clipset sends a clipboard set request to a noteserver. |
Program noteserver implements a server for posting notifications.
|
Program noteserver implements a server for posting notifications. |
clipper
Package clipper exports a service that manages the system clipboard, and provides named ancillary clipboard storage.
|
Package clipper exports a service that manages the system clipboard, and provides named ancillary clipboard storage. |
poster
Package poster implements a service that posts notifications to the user.
|
Package poster implements a service that posts notifications to the user. |
user
Package user exports a service to read input from the user.
|
Package user exports a service to read input from the user. |
Program postnote sends a notification request to a noteserver.
|
Program postnote sends a notification request to a noteserver. |
Program useredit requests editing of a file.
|
Program useredit requests editing of a file. |
Program usertext requests text from the user.
|
Program usertext requests text from the user. |
Program voicenote sends a voice notification request to a noteserver.
|
Program voicenote sends a voice notification request to a noteserver. |