item¶
Alfred Workflow Script Filter Item module.
- class afwf.item.Icon(*, path: str, type: str | None = None)[source]¶
Represent an icon object in a Script Filter item.
Ref: search
icon : OBJECTin https://www.alfredapp.com/help/workflows/inputs/script-filter/json/- TypeEnum¶
alias of
IconTypeEnum
- classmethod from_image_file(path: str) Icon[source]¶
Create an Icon using a local file’s path as the icon image.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class afwf.item.Text(*, copy: str | None = None, largetype: str | None = None)[source]¶
Represent the
textobject in a Script Filter item.copy— text copied to clipboard when the user presses ⌘Clargetype— text shown with Alfred Large Type (⌘L)
If neither field is set Alfred falls back to using
arg.Ref: search
text : OBJECTin https://www.alfredapp.com/help/workflows/inputs/script-filter/json/- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class afwf.item.Item(*, title: str, subtitle: str | None = None, arg: str | None = None, autocomplete: str | None = None, icon: ~afwf.item.Icon | None = None, valid: bool = True, uid: str | None = None, match: str | None = None, type: str | None = None, mods: dict | None = None, action: str | list[str] | dict[str, ~typing.Any] | None = None, text: ~afwf.item.Text | None = None, quicklookurl: str | None = None, variables: dict = <factory>)[source]¶
Data model for an Alfred Script Filter dropdown menu item.
Field names match the Alfred JSON spec exactly.
Ref: https://www.alfredapp.com/help/workflows/inputs/script-filter/json/
Note
``mods`` and ``variables`` inheritance — when a mod entry contains a
variableskey it replaces (not merges with) the item’svariables. An explicit"variables": {}on a mod prevents inheriting item variables. SeeModEnum.- TypeEnum¶
alias of
ItemTypeEnum
- set_modifier(mod: str | ModEnum = ModEnum.cmd, subtitle: str | None = None, arg: str | None = None, valid: bool = True) Item[source]¶
Add a modifier key override to this item.
When the user holds the modifier key while actioning the item, Alfred uses the values defined here instead of the item’s top-level fields.
- Parameters:
mod – modifier key — use
ModEnumvalues (e.g.ModEnum.cmd,ModEnum.cmd_alt)subtitle – alternate subtitle shown while the modifier is held
arg – alternate argument passed to the connected action
valid – whether the item is actionable with this modifier held
- open_file(path: str) Item[source]¶
Set variables to tell subsequence Alfred action to open a file.
Use the “Utilities -> Conditional” widget and set: if
{var:open_file}is equal to “y”.Use the “Actions -> Open File” widget and set: File:
{var:open_file_path}- Parameters:
path – the absolute path of the file to open
- launch_app_or_file(path: str) Item[source]¶
Set variables to tell subsequence Alfred action to launch an app or file.
Use the “Utilities -> Conditional” widget and set: if
{var:launch_app_or_file}is equal to “y”.Use the “Actions -> Launch Apps / Files” widget.
- Parameters:
path – the absolute path of the file or app to launch
- reveal_file_in_finder(path: str) Item[source]¶
Set variables to tell subsequence Alfred action to reveal a file in Finder.
Use the “Utilities -> Conditional” widget and set: if
{var:reveal_file_in_finder}is equal to “y”.Use the “Actions -> Reveal File in Finder” widget.
- Parameters:
path – the absolute path of the file to reveal in Finder
- browse_in_terminal(path: str) Item[source]¶
Set variables to tell subsequence Alfred action to browse in terminal.
Use the “Utilities -> Conditional” widget and set: if
{var:browse_in_terminal}is equal to “y”.Use the “Actions -> Browse in Terminal” widget.
- browse_in_alfred(path: str) Item[source]¶
Set variables to tell subsequence Alfred action to browse in Alfred.
Use the “Utilities -> Conditional” widget and set: if
{var:browse_in_alfred}is equal to “y”.Use the “Actions -> Browse in Alfred” widget.
- open_url(url: str) Item[source]¶
Set variables to tell subsequence Alfred action to open a URL.
Use the “Utilities -> Conditional” widget and set: if
{var:open_url}is equal to “y”.Use the “Actions -> Open URL” widget and set: File =
{var:open_url_arg}- Parameters:
url – the URL to open in browser
- run_script(cmd: str) Item[source]¶
Set variables to tell subsequence Alfred action to run a script.
Use the “Utilities -> Conditional” widget and set: if
{var:run_script}is equal to “y”.Use the “Actions -> Run Script” widget and set:
Language =
/bin/bash“with input as {query}”
running instances = “Sequentially”
Script =
{query}
- Parameters:
cmd – the full command to run, for example
python3 /path/to/test.py
Note
Also sets
item.argtocmdso the command is passed through Alfred’s connected action automatically.
- terminal_command(cmd: str) Item[source]¶
Set variables to tell subsequence Alfred action to run a terminal command.
Use the “Utilities -> Conditional” widget and set: if
{var:terminal_command}is equal to “y”.Use the “Actions -> Terminal Command” widget and set: Command =
{query}- Parameters:
cmd – the full command to run in terminal
Note
Also sets
item.argtocmdso the command is passed through Alfred’s connected action automatically.
- send_notification(title: str, subtitle: str = '') Item[source]¶
Set variables to tell subsequence Alfred action to send a notification.
Use the “Utilities -> Conditional” widget and set: if
{var:send_notification}is equal to “y”.Use the “Outputs -> Post Notification” widget and set:
Title =
{var:send_notification_title}Subtitle =
{var:send_notification_subtitle}
- Parameters:
title – the title of the notification
subtitle – the subtitle of the notification
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].