launch_helper

package
Version: v0.0.0-...-6789dc4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: GPL-3.0, GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

launch_helper wraps lomiri_app_launch to enable using application helpers. The useful part is HelperRunner

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCantFindHelper   = errors.New("can't find helper")
	ErrCantFindLauncher = errors.New("can't find launcher for helper")
)
View Source
var GetTempDir func(pkgName string) (string, error) = _getTempDir

override GetTempDir for testing without writing to ~/.cache/<pkgName>

View Source
var InputBufferSize = 10

Functions

func DefaultLaunchers

func DefaultLaunchers(log logger.Logger) map[string]HelperLauncher

DefaultLaunchers produces the default map for kind -> HelperLauncher

Types

type Card

type Card struct {
	Summary      string   `json:"summary"`   // required for the card to be presented
	Body         string   `json:"body"`      // defaults to empty
	Actions      []string `json:"actions"`   // if empty (default), bubble is non-clickable. More entries change it to be clickable and (for bubbles) snap-decisions.
	Icon         string   `json:"icon"`      // an icon relating to the event being notified. Defaults to empty (no icon); a secondary icon relating to the application will be shown as well, irrespectively.
	RawTimestamp int      `json:"timestamp"` // seconds since epoch, only used for persist (for now). Timestamp() returns this if non-zero, current timestamp otherwise.
	Persist      bool     `json:"persist"`   // whether to show in notification centre; defaults to false
	Popup        bool     `json:"popup"`     // whether to show in a bubble. Users can disable this, and can easily miss them, so don't rely on it exclusively. Defaults to false.
}

a Card is the usual “visual” presentation of a notification, used for bubbles and the notification centre (neé messaging menu)

func (*Card) Timestamp

func (card *Card) Timestamp() int64

Timestamp() returns RawTimestamp if non-zero. If it's zero, returns the current time as second since epoch.

type EmblemCounter

type EmblemCounter struct {
	Count   int32 `json:"count"`   // the number to show on the emblem counter
	Visible bool  `json:"visible"` // whether to show the emblem counter
}

an EmblemCounter puts a number on an emblem on an app's icon in the launcher

type HelperArgs

type HelperArgs struct {
	Input      *HelperInput
	AppId      string
	FileIn     string
	FileOut    string
	Timer      *time.Timer
	ForcedStop bool
}

type HelperInput

type HelperInput struct {
	App            *click.AppId
	NotificationId string
	Payload        json.RawMessage
	// contains filtered or unexported fields
}

HelperInput is what's passed in to a helper for it to work

type HelperLauncher

type HelperLauncher interface {
	HelperInfo(app *click.AppId) (string, string)
	InstallObserver(done func(string)) error
	RemoveObserver() error
	Launch(appId string, exec string, f1 string, f2 string) (string, error)
	Stop(appId string, instanceId string) error
}

type HelperOutput

type HelperOutput struct {
	Message      json.RawMessage `json:"message,omitempty"`      // what to put in the post office's queue
	Notification *Notification   `json:"notification,omitempty"` // what to present to the user
}

HelperOutput is the expected output of a helper

type HelperPool

type HelperPool interface {
	Run(kind string, input *HelperInput)
	Start() chan *HelperResult
	Stop()
}

func NewHelperPool

func NewHelperPool(launchers map[string]HelperLauncher, log logger.Logger) HelperPool

a HelperPool that delegates to different per kind HelperLaunchers

func NewTrivialHelperPool

func NewTrivialHelperPool(log logger.Logger) HelperPool

a trivial HelperPool that doesn't launch anything at all

type HelperResult

type HelperResult struct {
	HelperOutput
	Input *HelperInput
}

HelperResult is the result of a helper run for a particular app id

type Notification

type Notification struct {
	Card          *Card           `json:"card"`           // defaults to nil (no card)
	RawSound      json.RawMessage `json:"sound"`          // a boolean, or the relative path to a sound file. Users can disable this, so don't rely on it exclusively. Defaults to empty (no sound).
	RawVibration  json.RawMessage `json:"vibrate"`        // users can disable this, blah blah. Can be Vibration, or boolean. Defaults to null (no vibration)
	EmblemCounter *EmblemCounter  `json:"emblem-counter"` // puts a counter on an emblem in the launcher. Defaults to nil (no change to emblem counter).
	Tag           string          `json:"tag,omitempty"`  // tag used for Clear/ListPersistent.
}

a Notification can be any of the above

func (*Notification) Sound

func (notification *Notification) Sound(fallback string) string

func (*Notification) Vibration

func (notification *Notification) Vibration(fallback *Vibration) *Vibration

type Vibration

type Vibration struct {
	Pattern []uint32 `json:"pattern"`
	Repeat  uint32   `json:"repeat"` // defaults to 1. A value of zero is ignored (so it's like 1).
}

a Vibration generates a vibration in the form of a Pattern set in duration a pattern of on off states, repeated a number of times

Directories

Path Synopsis
package legacy implements a HelperLauncher for “legacy” applications.
package legacy implements a HelperLauncher for “legacy” applications.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL