common

package
v2.18.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package common provides common functions used by all providers.

Index

Constants

This section is empty.

Variables

View Source
var (
	LastMenuValue    = make(map[string]string)
	LastMenuValueMut sync.Mutex
)
View Source
var ErrConfigNotExists = errors.New("provider config doesn't exist")

Functions

func CacheFile

func CacheFile(file string) string

func ClipboardText added in v2.6.5

func ClipboardText() string

func ConfigDirs added in v2.1.3

func ConfigDirs() []string

func FileExists

func FileExists(filename string) bool

func ForceTerminalForFile

func ForceTerminalForFile(file string) bool

func FuzzyScore

func FuzzyScore(input, target string, exact bool) (int32, []int32, int32)

func GetLastMenuValue added in v2.14.0

func GetLastMenuValue(L *lua.LState) int

func GetTerminal

func GetTerminal() string

func GitPush added in v2.14.0

func GitPush(provider, file string, w *git.Worktree, r *git.Repository)

TODO: this needs better commit messages somehow...

func InitRunPrefix

func InitRunPrefix()

func JSONDecode added in v2.15.0

func JSONDecode(L *lua.LState) int

func JSONEncode added in v2.15.0

func JSONEncode(L *lua.LState) int

func LaunchPrefix

func LaunchPrefix(override string) string

func LoadConfig

func LoadConfig(provider string, config any)

func LoadGlobalConfig

func LoadGlobalConfig()

func LoadMenus

func LoadMenus()

func ProviderConfig

func ProviderConfig(provider string) (string, error)

func ReplaceResultOrStdinCmd

func ReplaceResultOrStdinCmd(replace, result string) *exec.Cmd

func SetExplicitDir

func SetExplicitDir(dir string)

func SetupGit added in v2.14.0

func SetupGit(provider string, cfg Gittable)

func TmpDir

func TmpDir() string

func WrapWithTerminal

func WrapWithTerminal(in string) string

Types

type Command added in v2.15.0

type Command struct {
	MustSucceed bool   `koanf:"must_succeed" desc:"will try running this command until it completes successfully" default:"false"`
	Command     string `koanf:"command" desc:"command to execute" default:""`
}

type Config

type Config struct {
	Icon                 string `koanf:"icon" desc:"icon for provider" default:"depends on provider"`
	NamePretty           string `koanf:"name_pretty" desc:"displayed name for the provider" default:"depends on provider"`
	MinScore             int32  `koanf:"min_score" desc:"minimum score for items to be displayed" default:"depends on provider"`
	HideFromProviderlist bool   `koanf:"hide_from_providerlist" desc:"hides a provider from the providerlist provider. provider provider." default:"false"`
}

type ElephantConfig

type ElephantConfig struct {
	AutoDetectLaunchPrefix bool      `koanf:"auto_detect_launch_prefix" desc:"automatically detects uwsm, app2unit or systemd-run" default:"true"`
	OverloadLocalEnv       bool      `koanf:"overload_local_env" desc:"overloads the local env" default:"false"`
	IgnoredProviders       []string  `koanf:"ignored_providers" desc:"providers to ignore" default:"<empty>"`
	GitOnDemand            bool      `koanf:"git_on_demand" desc:"sets up git repositories on first query instead of on start" default:"true"`
	BeforeLoad             []Command `koanf:"before_load" desc:"commands to run before starting to load the providers" default:""`
}

func GetElephantConfig

func GetElephantConfig() *ElephantConfig

type Entry

type Entry struct {
	Text        string            `toml:"text" desc:"text for entry"`
	Async       string            `toml:"async" desc:"if the text should be updated asynchronously based on the action"`
	Subtext     string            `toml:"subtext" desc:"sub text for entry"`
	Value       string            `toml:"value" desc:"value to be used for the action."`
	Actions     map[string]string `toml:"actions" desc:"actions items can use"`
	Terminal    bool              `toml:"terminal" desc:"runs action in terminal if true"`
	Icon        string            `toml:"icon" desc:"icon for entry"`
	SubMenu     string            `toml:"submenu" desc:"submenu to open, if has prefix 'dmenu:' it'll launch that dmenu"`
	Preview     string            `toml:"preview" desc:"filepath for the preview"`
	PreviewType string            `toml:"preview_type" desc:"type of the preview: text, file [default], command"`
	Keywords    []string          `toml:"keywords" desc:"searchable keywords"`
	State       []string          `toml:"state" desc:"state of an item, can be used to f.e. mark it as current"`

	Identifier string `toml:"-"`
	Menu       string `toml:"-"`
}

func (Entry) CreateIdentifier

func (e Entry) CreateIdentifier() string

type Gittable added in v2.14.0

type Gittable interface {
	SetLocation(string)
	URL() string
	SetWorktree(*git.Worktree)
	SetRepository(*git.Repository)
}
type Menu struct {
	HideFromProviderlist bool              `toml:"hide_from_providerlist" desc:"hides a provider from the providerlist provider. provider provider." default:"false"`
	Name                 string            `toml:"name" desc:"name of the menu"`
	NamePretty           string            `toml:"name_pretty" desc:"prettier name you usually want to display to the user."`
	Description          string            `toml:"description" desc:"used as a subtext"`
	Icon                 string            `toml:"icon" desc:"default icon"`
	Action               string            `toml:"action" desc:"default menu action to use"`
	Actions              map[string]string `toml:"actions" desc:"global actions"`
	AsyncActions         []string          `toml:"async_actions" desc:"set which actions should update the item on the client asynchronously"`
	SearchName           bool              `toml:"search_name" desc:"wether to search for the menu name as well when searching globally" default:"false"`
	Cache                bool              `toml:"cache" desc:"will cache the results of the lua script on startup"`
	RefreshOnChange      []string          `` /* 131-byte string literal not displayed */
	Entries              []Entry           `toml:"entries" desc:"menu items"`
	Terminal             bool              `toml:"terminal" desc:"execute action in terminal or not"`
	Keywords             []string          `toml:"keywords" desc:"searchable keywords"`
	FixedOrder           bool              `toml:"fixed_order" desc:"don't sort entries alphabetically"`
	History              bool              `toml:"history" desc:"make use of history for sorting"`
	HistoryWhenEmpty     bool              `toml:"history_when_empty" desc:"consider history when query is empty"`
	MinScore             int32             `toml:"min_score" desc:"minimum score for items to be displayed" default:"depends on provider"`
	Parent               string            `toml:"parent" desc:"defines the parent menu" default:""`
	SubMenu              string            `toml:"submenu" desc:"defines submenu to trigger on activation" default:""`

	// internal
	LuaString string
	IsLua     bool `toml:"-"`
}
func (m *Menu) CreateLuaEntries(query string)
func (m *Menu) GetState(L *lua.LState) int
func (m *Menu) NewLuaState() *lua.LState
func (m *Menu) SetState(L *lua.LState) int
type MenuConfig struct {
	Config `koanf:",squash"`
	Paths  []string `koanf:"paths" desc:"additional paths to check for menu definitions." default:""`
}
var (
	MenuConfigLoaded MenuConfig

	Menus = make(map[string]*Menu)
)

type PushData added in v2.14.0

type PushData struct {
	// contains filtered or unexported fields
}

type Repo added in v2.14.0

type Repo struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis
Package history provides functions to save and load history in a streamlined way.
Package history provides functions to save and load history in a streamlined way.
Package wlr implements the wlr_foreign_toplevel_management_unstable_v1 protocol
Package wlr implements the wlr_foreign_toplevel_management_unstable_v1 protocol

Jump to

Keyboard shortcuts

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