Skip to content

WShawnMing/Glance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Glance

Glance app icon

A blink-fast, LLM-powered selection translator for macOS — lives in your menu bar.

Release CI Platform License

What it does

Select any text in any macOS app, fire a hotkey (or double-tap ⌘C), and a translucent panel slides out from the menu bar with the translation. Works in Safari, Notes, Mail, Xcode, VSCode, Cursor, Preview/PDF, and most native + Electron apps.

Powered by any OpenAI-compatible Chat Completions endpoint (OpenAI, DeepSeek, Qwen, SiliconFlow, OpenRouter, your own proxy, etc.). 11 built-in translation styles (general, academic, technology, news, finance, novel, medical, legal, GitHub, etc.).

Install

Option 1: download the DMG

  1. Grab Glance-*.dmg from the latest release.
  2. Open the DMG, drag Glance.app into Applications.
  3. Launch Glance. If macOS blocks it with "unable to verify the developer":
    • Right-click Glance.app → Open → confirm in the dialog. Or:
    • xattr -dr com.apple.quarantine /Applications/Glance.app
  4. Grant Accessibility permission when prompted (or in System Settings → Privacy & Security → Accessibility).

Option 2: build from source

Requires Xcode 15+ (for the Swift 5.9 toolchain).

git clone https://github.com/WShawnMing/Glance.git
cd Glance
./scripts/build-app.sh
open dist/Glance.app

Universal binary (Apple Silicon + Intel):

UNIVERSAL=1 ./scripts/build-app.sh

Build the DMG installer:

UNIVERSAL=1 ./scripts/build-dmg.sh   # → dist/Glance-x.y.z.dmg

First-run setup

  1. Click the Glance icon in the menu bar → ⚙ to open settings.
  2. Fill in:
    • Base URL — e.g. https://api.openai.com/v1, https://api.siliconflow.cn/v1, https://api.deepseek.com/v1
    • API Key
    • Model — e.g. gpt-4.1-mini, deepseek-chat, Qwen/Qwen2.5-72B-Instruct
  3. Hit Test connection to confirm.
  4. Pick a translation mode and target language.
  5. Pick a trigger:
    • Global hotkey (default ⌃⌥⌘T) — uses macOS Accessibility to read the selection
    • Double ⌘C — press ⌘C twice within 400 ms to trigger; reads the clipboard

Daily use

  1. Select text in any app.
  2. Press the trigger.
  3. A translucent panel slides out below the menu-bar icon with the translation.
  4. Click the copy icon (or ⌘C while the panel is focused) to copy the result.
  5. Click outside or press Esc to dismiss.

Works across Mission Control Spaces and fullscreen apps.

Repo layout

Sources/
  GlanceCore/                          # platform-agnostic translation pipeline
    Types.swift                        # mode / result / error types
    TranslationModes.swift             # 11 built-in modes
    TranslationClient.swift            # URL normalize, system-role fallback, response parsing
    Settings.swift                     # AppSettings + persistence
  GlanceApp/                           # macOS shell
    App.swift / AppDelegate.swift      # @main, status item, popover, hotkey wiring
    Hotkey/HotkeyManager.swift         # Carbon RegisterEventHotKey
    Hotkey/DoubleCommandCMonitor.swift # CGEventTap for double-⌘C
    Selection/SelectionReader.swift    # AX selection + clipboard fallback
    UI/PopoverView.swift               # SwiftUI translation panel
    UI/SettingsView.swift              # SwiftUI settings window
    UI/HotkeyRecorderView.swift        # record arbitrary keyboard shortcut
    Resources/Info.plist.template
    Resources/AppIcon.icns
Tests/GlanceTests/                     # unit tests (URL normalize / fallbacks / array-content / modes)
scripts/
  build-app.sh                         # swift build → .app bundle (ad-hoc signed)
  build-dmg.sh                         # build-app.sh → hdiutil → Glance-x.y.z.dmg
  make-icon.py                         # regenerate AppIcon.icns from Python (Pillow)
.github/workflows/
  ci.yml                               # tests + .app build on every push
  release.yml                          # build universal + DMG on tag, publish GitHub release

How it reads selection

  • Accessibility path (preferred)AXUIElementCopyAttributeValue(focused, kAXSelectedTextAttribute). Works in Safari, Notes, Mail, Xcode, Preview, native apps.
  • Clipboard fallback — if AX returns nothing, Glance:
    1. Waits for the user's modifier keys to release
    2. Snapshots the pasteboard contents
    3. Synthesises ⌘C via CGEvent
    4. Reads the new pasteboard string
    5. Restores the original pasteboard contents
  • Double ⌘C mode — never touches the pasteboard itself; the user's two ⌘C presses put the text there, Glance just reads it.

Roadmap

  • Streaming output
  • Per-app trigger overrides
  • Custom translation modes UI
  • Move API key to Keychain
  • Optional automatic update via Sparkle

License

MIT. Translation pipeline and prompt templates ported from sibling projects:

About

划词翻译软件

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors