entry

package
v0.0.0-...-8fec888 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathProviderKey     = "path-provider"
	OptionBaseDirectory = "base-directory"
	OptionHideFiles     = "hide-files"
	OptionHideFolders   = "hide-folders"
	OptionIgnoreVCS     = "no-ignore-vcs"
)
View Source
const ApplicationProviderKey = "application-provider"

Uniform identifier

Deprecated: use DesktopFileProvider for fewer dependencies and issues

View Source
const CommandProviderKey = "command-provider"
View Source
const DesktopFileProviderKey = "desktopFile-provider"
View Source
const ShortCutProviderKey = "shortcut-provider"

Variables

View Source
var (
	ErrNotFound       = errors.New("entry not found in this provider")
	ErrRemoteRequired = errors.New("a remote is required for this entry")
)
View Source
var (
	ErrTypeAlreadyRegistered = errors.New("type already registered")
	ErrTypeNotRegistered     = errors.New("type not registered")
	ErrVersionMisMatch       = errors.New("serialized entry was built with a different version of the launcher")
)
View Source
var (
	ErrInvalidScheme = errors.New("forbidden scheme in URL")
)
View Source
var (
	ErrKeyNotHandled = fmt.Errorf("key not handled")
)
View Source
var ErrUnableToRemoteLaunchCommand = errors.New("unable to RemoteLaunch() this command")

Functions

func AddCommandsToConfig

func AddCommandsToConfig(conf *config.Config, commands map[string]Command, override bool) error

func AddShortcutsToConfig

func AddShortcutsToConfig(conf *config.Config, shortcuts map[string]ShortCut, override bool) error

func GetRegisteredProviderFun

func GetRegisteredProviderFun() map[string]NewEntryProviderFun

func RegisterEntryType

func RegisterEntryType[T Entry]() error

Register a type to be serialized

func ScanDirectory

func ScanDirectory(dir string, blacklist map[string]struct{}) (map[string]DesktopFile, error)

func ScanMulti

func ScanMulti(directories []string, blacklist map[string]struct{}) (map[string]DesktopFile, error)

func Serialize

func Serialize(entry Entry) ([]byte, error)

Serialize an entry to a byte slice. NOTE: the then de-serialized entry will be a pointer type. NOTE: the type of the entry MUST be registered beforehand (see RegisterEntryType[T]()).

func SerializeWithOptions

func SerializeWithOptions(entry Entry, options map[string]string) ([]byte, error)

func SetApplicationConfig deprecated

func SetApplicationConfig(
	conf *config.Config,
	pythonPath string,
	blacklist []string,
	extraApplication map[string]string,
) error

Update the config the the ApplicationProvider

Deprecated: use DesktopFileProvider for fewer dependencies and issues

func SetDfConfig

func SetDfConfig(
	conf *config.Config,
	blacklist []string,
) error

func SetPathProviderSettings

func SetPathProviderSettings(conf *config.Config, settings PathProviderSettings) error

Types

type Application deprecated

type Application struct {
	AppId     string  `json:"app-id"`
	PythonBin *string `json:"python-bin"`
}

identifier (e.g. "org.gnome.Calendar.desktop") for an application to launch

Deprecated: use DesktopFileProvider for fewer dependencies and issues

func (Application) LaunchInFrontend deprecated

func (a Application) LaunchInFrontend(_ frontend.Frontend, options map[string]string) error

Deprecated: use DesktopFileProvider for fewer dependencies and issues

func (Application) RemoteLaunch deprecated

func (a Application) RemoteLaunch(options map[string]string) error

Deprecated: use DesktopFileProvider for fewer dependencies and issues

type ApplicationProvider deprecated

type ApplicationProvider = MapProvider[Application]

Deprecated: use DesktopFileProvider for fewer dependencies and issues

type Command

type Command struct {
	Name string   `json:"name"`
	Args []string `json:"args"`
	// how much should we wait before exiting after a successful run
	SecondDelay int `json:"second_delay"`
	// failure leave the window open by default
	CloseOnFailure bool `json:"close_on_failure"`
}

command to run in the current terminal

func (Command) LaunchInFrontend

func (c Command) LaunchInFrontend(_ frontend.Frontend, _ map[string]string) error

func (Command) RemoteLaunch

func (c Command) RemoteLaunch(options map[string]string) error

type CommandProvider

type CommandProvider = MapProvider[Command]

provide commands

type DesktopFile

type DesktopFile struct {
	Name       string
	Identifier string
}

func Read

func Read(path string) (df DesktopFile, shouldShow bool, err error)

func (DesktopFile) LaunchInFrontend

func (d DesktopFile) LaunchInFrontend(_ frontend.Frontend, options map[string]string) error

func (DesktopFile) RemoteLaunch

func (d DesktopFile) RemoteLaunch(options map[string]string) error

type DesktopFileProvider

type DesktopFileProvider = MapProvider[DesktopFile]

type Entry

type Entry interface {
	// LaunchInFrontend launches the entry in the provided frontend
	LaunchInFrontend(f frontend.Frontend, options map[string]string) error
	// RemoteLaunch should be used by the remote to launch the entry in a different process
	RemoteLaunch(options map[string]string) error
}

func Deserialize

func Deserialize(data []byte) (Entry, error)

Return a new entry from the serialization NOTE: the de-serialized entry will be a pointer type. NOTE: the type of the entry MUST be registered beforehand (see RegisterEntryType[T]())

func DeserializeWithOption

func DeserializeWithOption(data []byte) (entry Entry, options map[string]string, err error)

type EntryProvider

type EntryProvider interface {
	// returns a reader from which all keywords can be read
	GetEntryReader() (io.Reader, error)
	// returns a value for an entry
	Fetch(entry string) (Entry, bool)
	// whether the provider is independent of the remote
	IsRemoteIndependent() bool
}

func GetProviders

func GetProviders(
	conf *config.Config,
	options map[string]string,
	builders ...NewEntryProviderFun,
) ([]EntryProvider, error)

func NewApplicationProvider deprecated

func NewApplicationProvider(conf *config.Config, options map[string]string) (EntryProvider, error)

Build a new ApplicationProvider

Deprecated: use DesktopFileProvider for fewer dependencies and issues

func NewCommandProvider

func NewCommandProvider(conf *config.Config, options map[string]string) (EntryProvider, error)

func NewDesktopFileProvider

func NewDesktopFileProvider(conf *config.Config, options map[string]string) (EntryProvider, error)

func NewPathProvider

func NewPathProvider(conf *config.Config, options map[string]string) (EntryProvider, error)

func NewShortcutProvider

func NewShortcutProvider(conf *config.Config, options map[string]string) (EntryProvider, error)

type MapProvider

type MapProvider[T Entry] struct {
	Content           map[string]T
	Prefix            string
	RemoteIndependent bool
}

func (MapProvider[T]) Fetch

func (mp MapProvider[T]) Fetch(entry string) (Entry, bool)

func (MapProvider[T]) GetEntryReader

func (mp MapProvider[T]) GetEntryReader() (io.Reader, error)

func (MapProvider[T]) IsRemoteIndependent

func (mp MapProvider[T]) IsRemoteIndependent() bool

type NewEntryProviderFun

type NewEntryProviderFun = func(*config.Config, map[string]string) (EntryProvider, error)

type Path

type Path string

absolute path to open with xdg-open

func (Path) LaunchInFrontend

func (p Path) LaunchInFrontend(_ frontend.Frontend, options map[string]string) error

func (Path) RemoteLaunch

func (p Path) RemoteLaunch(options map[string]string) error

type PathProvider

type PathProvider struct {
	PathProviderSettings
}

provide path on the disk

func (PathProvider) Fetch

func (p PathProvider) Fetch(entry string) (Entry, bool)

func (PathProvider) GetEntryReader

func (p PathProvider) GetEntryReader() (io.Reader, error)

func (PathProvider) IsRemoteIndependent

func (p PathProvider) IsRemoteIndependent() bool

type PathProviderSettings

type PathProviderSettings struct {
	FdfindPath    string `json:"fdfind-path"`
	BaseDirectory string `json:"base-directory"`
	NoIgnoreVCS   bool   `json:"no-ignore-vcs"`
	HideFiles     bool   `json:"hide-files"`
	HideFolders   bool   `json:"hide-folders"`
}

type ShortCut

type ShortCut string

either an URI or an absolute path

func (ShortCut) LaunchInFrontend

func (s ShortCut) LaunchInFrontend(_ frontend.Frontend, _ map[string]string) error

func (ShortCut) RemoteLaunch

func (s ShortCut) RemoteLaunch(options map[string]string) error

type ShortCutProvider

type ShortCutProvider = MapProvider[ShortCut]

provide URIs and path as shortcuts

Jump to

Keyboard shortcuts

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