Reference

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 python3 or #!/usr/bin/env -S uv run --script. Otherwise the extension does: .py Python, .js .mjs .cjs Node, .sh sh, .ps1 PowerShell, .cmd .bat Command Prompt. The file doesn't need to be executable.
  • On Windows, Python is found as python, then py, then python3. Save a .ps1 that 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

@glimpse.description Answers a question.Shown on the action's card, up to two lines.
@glimpse.shortcut Control+Alt+ARuns 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 intoRuns when a dictation starts with this phrase. The phrase is removed from the text.
@glimpse.on dictation.savedRuns on an event: dictation.saved, library.added, library.complete or library.error.
@glimpse.app SlackOnly runs in this app.
@glimpse.site github.comOnly runs on this website, and its subdomains.
@glimpse.show insertTypes what the script prints. The default, toast, shows it as a notice.
@glimpse.timeout 60Seconds before Glimpse stops it. Default 30, 0 for no limit.
@glimpse.listen falseThe 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.say line 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.app or @glimpse.site lines 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 false keys and other events.

In its environment:

GLIMPSE_PHRASEThe phrase that matched
GLIMPSE_EVENTThe event that fired
GLIMPSE_IDThe History or Library item this run is about
GLIMPSE_LANGUAGELanguage code
GLIMPSE_AUDIO_FILEThe recording
GLIMPSE_APPThe app you were in
GLIMPSE_WINDOW_TITLEIts window title
GLIMPSE_URLThe page you were on
GLIMPSE_SELECTED_TEXTThe selected text
GLIMPSE_FIELD_TEXTThe text of the field you were typing in
GLIMPSE_STATE_DIRA folder the action keeps between runs
GLIMPSE_HEADLESS1 in a test run
  • The script runs in its own folder.
  • On Mac it gets your shell's environment, from ~/.zshrc and ~/.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.
  • glimpse is always on the PATH. LANG is UTF-8 and PYTHONUTF8=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

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 cleanCleans up standard input the way dictation cleanup does, with the mode for the app in front. Needs a writing model.
glimpse actions listShows 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 actionsOpens 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.