Reference
The file
- One action, one file. The file name without its extension is the action's name.
- Header lines are comments at the top of the file, before the first line of code. Any comment style works:
#,//,--,REM,::. - The
#!line picks the program that runs it, like#!/usr/bin/env python3or#!/usr/bin/env -S uv run --script. Otherwise the extension does:.pyPython,.js.mjs.cjsNode,.shsh,.ps1PowerShell,.cmd.batCommand Prompt. The file doesn't need to be executable. - On Windows, Python is found as
python, thenpy, thenpython3. Save a.ps1that contains non-English text as UTF-8 with BOM, or Windows PowerShell 5.1 reads it as ANSI. - Files must be UTF-8. A UTF-16 file shows a problem.
Header lines
| Line | Meaning |
|---|---|
| @glimpse.description Answers a question. | Shown on the action's card, up to two lines. |
| @glimpse.shortcut Control+Alt+A | Runs on this key. Add smart, hold or toggle after it. Smart is the default: tap to start and stop, or hold while you talk. CmdOrCtrl works on both platforms. |
| @glimpse.say translate into | Runs when a dictation starts with this phrase. The phrase is removed from the text. |
| @glimpse.on dictation.saved | Runs on an event: dictation.saved, library.added, library.complete or library.error. |
| @glimpse.app Slack | Only runs in this app. |
| @glimpse.site github.com | Only runs on this website, and its subdomains. |
| @glimpse.show insert | Types what the script prints. The default, toast, shows it as a notice. |
| @glimpse.timeout 60 | Seconds before Glimpse stops it. Default 30, 0 for no limit. |
| @glimpse.listen false | The shortcut runs the script at once, without a dictation. |
shortcut, say, on, app and site can repeat. Unknown keys, bad values and other keys written twice show as problems.
Phrases and shortcuts
- A phrase with no shortcut works on your normal dictation shortcuts. It needs two or more words (two or more characters in Chinese, Japanese, Korean or Thai), so ordinary sentences don't trigger it.
- Several actions can share one shortcut, each with its own phrase. The phrase you start with picks the action, so one-word phrases like "open" are fine there. With no matching phrase, Glimpse says "No action for …".
- Matching ignores case and punctuation and works on whole words. The longer phrase wins. On a tie, the action limited to an app or website wins.
- Replacements apply before matching, so a replacement can fix a phrase the speech model keeps mishearing. A second
@glimpse.sayline with the misheard spelling works too. - Phrases are checked before cleanup and Edit Mode. Select text and say an action's phrase, and the action runs and gets the selection.
- Several
@glimpse.appor@glimpse.sitelines mean any of them. App and site together mean both. - Normal dictation does no extra work unless an action with a phrase is switched on.
What the script gets
On standard input:
- What you said, with the phrase removed.
- For
dictation.saved, the dictation as saved. - For
library.complete, the recording's transcript. - Nothing for
listen falsekeys and other events.
In its environment:
| Variable | Contents |
|---|---|
| GLIMPSE_PHRASE | The phrase that matched |
| GLIMPSE_EVENT | The event that fired |
| GLIMPSE_ID | The History or Library item this run is about |
| GLIMPSE_LANGUAGE | Language code |
| GLIMPSE_AUDIO_FILE | The recording |
| GLIMPSE_APP | The app you were in |
| GLIMPSE_WINDOW_TITLE | Its window title |
| GLIMPSE_URL | The page you were on |
| GLIMPSE_SELECTED_TEXT | The selected text |
| GLIMPSE_FIELD_TEXT | The text of the field you were typing in |
| GLIMPSE_STATE_DIR | A folder the action keeps between runs |
| GLIMPSE_HEADLESS | 1 in a test run |
- The script runs in its own folder.
- On Mac it gets your shell's environment, from
~/.zshrcand~/.zprofile, so installed tools and exported API keys are found. Glimpse rereads it when the Actions screen opens. - On Windows it gets your user environment.
glimpseis always on the PATH.LANGis UTF-8 andPYTHONUTF8=1.
Output
- Exit 0 with output: a notice titled with the action's name, or typed with
@glimpse.show insert. Longer text stays up longer. - Exit 0 with no output: nothing happens.
- Any other exit: an error notice with the last line the script wrote to standard error. Print progress and logs to standard error, not standard output.
- Output over 1 MB is an error.
- An action that types holds the pill until it's done. Press its shortcut again to stop it. If you switch apps meanwhile, the result shows as a notice instead.
- Runs of one action wait their turn, in order. Stopping or timing out ends the script and everything it started.
- Dictations that went to an action stay in History, marked with the action's name.
Commands for scripts
| Command | Does |
|---|---|
| glimpse toast <message> | Shows a notice and returns at once. Line breaks are kept. Options: --title, --type info|success|warning|error, --duration in seconds (0 keeps it until closed). |
| glimpse pill <text> | Shows text in the pill while an action that types is running. |
| glimpse ask <question> | Asks you something and prints the answer: what you said (press your shortcut and speak), or the button you clicked. Up to two --button labels, questions up to 160 characters. Exits with 1 when skipped. |
| glimpse llm <instruction> | Sends standard input with the instruction to the writing model set in Settings and prints the reply. --local uses Glimpse C1.2, the model on this computer, which fits about 2,000 tokens. No web search: scripts that need it call their own API. |
| glimpse clean | Cleans up standard input the way dictation cleanup does, with the mode for the app in front. Needs a writing model. |
| glimpse actions list | Shows the folder, each action and its problems. |
| glimpse actions run [name] [text] | Runs an action and prints what it showed. Exit 0 worked, 3 failed or timed out, 4 stopped. Test options. |
| glimpse actions last <name> | Prints what its last run showed, from any trigger. |
| glimpse actions stop <name> | Ends its run and the runs waiting. |
| glimpse open actions | Opens the Actions screen. |
Text that starts with - is fine, like glimpse toast "- milk". Put -- before text that looks like a flag.
Limits and safety
- Scripts run as you, with the permissions Glimpse has, like the microphone and Accessibility. Only add scripts you trust.
- Glimpse reads the selection through Accessibility. It never presses Copy to get it.
- Call start and end events aren't available yet.
- Two actions that run each other by name wait on each other until one times out. An action can't run itself.