Skip to content

Actions

Garon edited this page Nov 23, 2026 · 1 revision

Actions

An action is one script file. Glimpse runs it when you press its shortcut or start a dictation with its phrase, hands it what you said, and shows or types what it prints. Write it in any language: Python, JavaScript, a shell script, PowerShell.

Actions need a license or the trial.

Your first action

Open Actions in the sidebar, click Open Folder, and save this as Ask.sh:

#!/bin/bash
# @glimpse.description Answers a question with the writing model on this computer.
# @glimpse.shortcut Control+Alt+Space
glimpse llm "Answer in at most three sentences." --local

Turn it on with its switch on the Actions screen. Hold Control+Alt+Space, ask a question, and the answer shows as a notice.

On the Actions screen, click an action to show its script in Finder (File Explorer on Windows). Right-click, or hold Shift and click, to move it to the Trash.

Header lines

Settings are comment lines at the top of the file, before the first line of code. Any comment style works (#, //, --, REM). The file name is the action's name.

Line Meaning
@glimpse.description Answers a question. Shown on the action's card.
@glimpse.shortcut Control+Alt+A Runs on this shortcut. Add hold or toggle after it to change how it works; the default is Smart (tap to start and stop, or hold). Repeatable.
@glimpse.say translate to Runs when a dictation starts with this phrase. The phrase is removed from the text. Repeatable, for words the speech model mishears.
@glimpse.on dictation.saved Runs on an event: dictation.saved, library.added, library.complete, library.error. Repeatable.
@glimpse.app Slack Only runs in this app. Repeatable.
@glimpse.site github.com Only runs on this website. Repeatable.
@glimpse.show insert Types what the script prints. The default, toast, shows it as a notice.
@glimpse.timeout 60 Seconds before Glimpse stops the script. The default is 30; 0 means no limit.
@glimpse.listen false The shortcut runs the script right away, without a dictation.

Mistakes in these lines show on the action's card and in glimpse actions list.

Shortcuts and phrases

  • A phrase with no shortcut works on your normal dictation shortcuts. It needs two or more words, so everyday 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 a single word like "open" is safe there.
  • Phrases ignore case and punctuation. When two match, the longer one wins, then the one limited to an app or website.
  • Replacements in Glimpse run before the match, so a replacement can fix a phrase the speech model keeps mishearing.
  • An action's shortcuts show in Settings, General under its name. Changing them there rewrites the line in the file.

What the script gets

What you said comes in on standard input, without the phrase. For dictation.saved it's the dictation as saved, and for library.complete the transcript. These variables describe the rest:

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, GLIMPSE_WINDOW_TITLE, GLIMPSE_URL Where you were
GLIMPSE_SELECTED_TEXT, GLIMPSE_FIELD_TEXT The selected text, and the text of the field you were typing in
GLIMPSE_STATE_DIR A folder for the action to keep things between runs

Scripts run in their own folder with your shell's environment on Mac, so tools you installed and keys you export in ~/.zshrc are found. glimpse is always on the path.

Output

  • If the script prints something and exits with 0, Glimpse shows it, or types it with @glimpse.show insert. Printing nothing does nothing.
  • Anything else shows an error notice with the last line the script wrote to standard error. Print progress and logs there, not to standard output.
  • An action that types holds the pill until it's done. Press its shortcut again to stop it. If you switch apps meanwhile, the answer shows as a notice instead.

Commands for scripts

Command Does
glimpse toast <message> [--title t] [--type info|success|warning|error] [--duration s] Shows a notice.
glimpse pill <text> Shows text in the pill while an action that types is running.
glimpse ask <question> [--button label]… Asks you something and prints the answer: what you said, or the button you clicked. Exits with 1 if you skip it.
glimpse llm <instruction> [--local] Sends standard input to the writing model in Settings, with the instruction, and prints the reply. --local uses the model on this computer.
glimpse clean Cleans up standard input the way dictation cleanup does.

Testing and agents

  • glimpse actions list shows the folder, each action and its problems, including conflicts with other actions before you switch it on.
  • glimpse actions run <name> "text" --headless runs an action and prints everything you would have seen, without showing or typing anything. It works whether or not the action's switch is on.
    • --answer <text> answers each question it asks, in order.
    • --say "translate into German good morning" goes through phrase matching the way a dictation would, so you can test which action a sentence reaches. Add --key <shortcut> to test a shared shortcut.
    • --event library.complete runs it as that event, with the text as its input.
    • --env GLIMPSE_APP=Slack sets what the script sees. It works for GLIMPSE_APP, GLIMPSE_WINDOW_TITLE, GLIMPSE_URL, GLIMPSE_SELECTED_TEXT, GLIMPSE_FIELD_TEXT, GLIMPSE_LANGUAGE and GLIMPSE_ID.
    • --json prints the record as data.
    • Exit codes: 0 when it worked, 3 when it failed or timed out, 4 when it was stopped.
  • Headless runs set GLIMPSE_HEADLESS=1. The script still really runs, so check it before doing anything you can't undo.
  • glimpse actions last <name> prints what the last run showed, so you can press the shortcut and then read what happened.
  • Over MCP, glimpse mcp offers list_actions and last_action_run. Add --allow-actions to also offer run_action, with the same options, so an agent can write an action, run it, read the record and fix it.

Examples

Translate and type:

#!/usr/bin/env python3
# @glimpse.say translate to
# @glimpse.show insert
import subprocess, sys
text = sys.stdin.read()
reply = subprocess.run(
    ["glimpse", "llm", "The first word is a language. Translate the rest into it. Reply with only the translation."],
    input=text, capture_output=True, text=True, check=True,
)
print(reply.stdout.strip())

Keep a journal of every dictation:

#!/bin/bash
# @glimpse.on dictation.saved
{ date '+%H:%M'; cat; echo; } >> ~/Documents/journal.md

Ask before posting:

#!/usr/bin/env python3
# @glimpse.say post standup
import subprocess, sys
text = sys.stdin.read()
answer = subprocess.run(["glimpse", "ask", "Post it?", "--button", "Post", "--button", "Cancel"],
                        capture_output=True, text=True).stdout.strip()
if answer == "Post":
    print("Posted")

Getting Started

Features

Help

Clone this wiki locally