xalfred

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModKeyCmd   = "cmd"   // ⌘
	ModKeyAlt   = "alt"   // ⌥
	ModKeyOpt   = "alt"   // ⌥
	ModKeyCtrl  = "ctrl"  // ^
	ModKeyShift = "shift" // ⇧
	ModKeyFn    = "fn"    // fn
)

...

Variables

View Source
var (
	IconWorkflow  = NewIcon("icon.png")
	IconAccount   = NewIcon(GetSysIconPath("Accounts.icns"))
	IconBurn      = NewIcon(GetSysIconPath("BurningIcon.icns"))
	IconClock     = NewIcon(GetSysIconPath("Clock.icns"))
	IconColor     = NewIcon(GetSysIconPath("ProfileBackgroundColor.icns"))
	IconColour    = NewIcon(GetSysIconPath("ProfileBackgroundColor.icns"))
	IconEject     = NewIcon(GetSysIconPath("EjectMediaIcon.icns"))
	IconError     = NewIcon(GetSysIconPath("AlertStopIcon.icns"))
	IconFavorite  = NewIcon(GetSysIconPath("ToolbarFavoritesIcon.icns"))
	IconFavourite = NewIcon(GetSysIconPath("ToolbarFavoritesIcon.icns"))
	IconGroup     = NewIcon(GetSysIconPath("GroupIcon.icns"))
	IconHelp      = NewIcon(GetSysIconPath("HelpIcon.icns"))
	IconHome      = NewIcon(GetSysIconPath("HomeFolderIcon.icns"))
	IconInfo      = NewIcon(GetSysIconPath("ToolbarInfo.icns"))
	IconNetwork   = NewIcon(GetSysIconPath("GenericNetworkIcon.icns"))
	IconNote      = NewIcon(GetSysIconPath("AlertNoteIcon.icns"))
	IconSettings  = NewIcon(GetSysIconPath("ToolbarAdvanced.icns"))
	IconSwirl     = NewIcon(GetSysIconPath("ErasingIcon.icns"))
	IconSwitch    = NewIcon(GetSysIconPath("General.icns"))
	IconSync      = NewIcon(GetSysIconPath("Sync.icns"))
	IconTrash     = NewIcon(GetSysIconPath("TrashIcon.icns"))
	IconUser      = NewIcon(GetSysIconPath("UserIcon.icns"))
	IconWarning   = NewIcon(GetSysIconPath("AlertCautionIcon.icns"))
	IconWeb       = NewIcon(GetSysIconPath("BookmarkIcon.icns"))
)

... 预设图标

Functions

func Dict

func Dict(v *Var)

Dict 变量, 适用于 Run Script 输出

func GetSysIconPath

func GetSysIconPath(name string) string

GetSysIconPath 获取系统图片路径

func List

func List(items []*Item)

List 列表, 适用于 Script Filter 列表输出

func Notice

func Notice(title, content string)

Notice 通知, 适用于 Post Notification

func Output

func Output(v interface{})

Output ...

func Row

func Row(title, subtitle string)

Row 错误或提示, 适用于 Script Filter 单行输出

Types

type Alfredworkflow

type Alfredworkflow struct {
	Arg       string `json:"arg"`
	Config    *Var   `json:"config"`
	Variables *Var   `json:"variables"` // 通过 {var:xxx} 使用
}

Alfredworkflow ...

type Icon

type Icon struct {
	Type IconType `json:"type,omitempty"`
	Path string   `json:"path"`
}

Icon ...

func NewIcon

func NewIcon(path string, types ...IconType) *Icon

NewIcon ...

type IconType

type IconType string

IconType 图标类型

const (
	// 图片, 值为对应图片路径
	IconTypeImage IconType = ""
	// 文件图标, "/Applications/Safari.app" 即显示对应应用的图片
	IconTypeFileIcon IconType = "fileicon"
	// 文件类型, "public.folder" "com.apple.rtfd"
	IconTypeFileType IconType = "filetype"
)

...

type Item

type Item struct {
	Uid          string      `json:"uid,omitempty"`          // 唯一标识
	Title        string      `json:"title"`                  // 主标题
	Subtitle     string      `json:"subtitle,omitempty"`     // 副标题
	Arg          string      `json:"arg,omitempty"`          // 传递的参数, 通过 {query} 访问
	Icon         *Icon       `json:"icon,omitempty"`         // 图标
	Valid        bool        `json:"valid,omitempty"`        // 是否有效, 默认 true, 无效时回车不执行任何操作
	Match        string      `json:"match,omitempty"`        // Filters Results
	Autocomplete string      `json:"autocomplete,omitempty"` // Tab 健自动补全
	Type         string      `json:"type,omitempty"`         // 类型, 默认 default(default/file/file:skipcheck)
	Mods         *Mod        `json:"mods,omitempty"`         // 控制按键回车时可变更 subtitle, icon, arg 等
	Action       interface{} `json:"action,omitempty"`       // 定义 Universal Action, 类型 object/array/string
	Text         *Text       `json:"text,omitempty"`         // 定义 cmd+c 复制和 cmd+l 显示时的文本
	Quicklookurl string      `json:"quicklookurl,omitempty"` // 快速预览, shift 或者 cmd+y, 无则使用 arg
	Variables    *Var        `json:"variables,omitempty"`    // 传递的变量, 通过 {var:xxx} 访问
}

Item 对应 script filter 中的列表项

func NewItem

func NewItem(title, subtitle string) *Item

NewItem ...

type Mod

type Mod map[ModKey]*ModItem

Mod ...

type ModItem

type ModItem struct {
	Key       string   `json:"key,omitempty"`
	Subtitle  string   `json:"subtitle,omitempty"`
	Icon      *Icon    `json:"icon,omitempty"`
	Valid     bool     `json:"valid,omitempty"`
	Arg       []string `json:"arg,omitempty"`
	Variables *Var     `json:"variables,omitempty"`
}

ModItem ...

type ModKey

type ModKey string

ModKey ...

func (ModKey) Plus

func (t ModKey) Plus(k ModKey) ModKey

Plus 支持组合 cmd + shift

type Response

type Response struct {
	Rerun          bool              `json:"rerun,omitempty"`          // 为 true 时再次执行(时间秒针变化)
	Skipknowledge  bool              `json:"skipknowledge,omitempty"`  // xxx
	Variables      map[string]string `json:"variables,omitempty"`      // 设置变量, 可被 items 使用
	Items          []*Item           `json:"items,omitempty"`          // 输出列表
	Alfredworkflow *Alfredworkflow   `json:"alfredworkflow,omitempty"` // 输出变量
}

ScriptFilter 对应 Script Filter 组件返回 https://www.alfredapp.com/help/workflows/inputs/script-filter/json/

type Text

type Text struct {
	Copy      string `json:"copy,omitempty"`      // cmd+c 复制
	Largetype string `json:"largetype,omitempty"` // cmd+l 显示
}

Text ...

type Var

type Var map[string]interface{}

Var ...

Jump to

Keyboard shortcuts

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