Skip to content

About

A macOS menu bar app for instant text processing, translation, lookup, and web search on any selected text

Resources

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

SelectionBar

SelectionBar app icon

CI Latest Release Platform License

A macOS menu bar app that shows a floating toolbar when you select text. Copy, search, look up, translate, speak, chat with AI, run shell commands, or build reusable LLM, JavaScript, key-binding, and pipeline actions.

Features

Quick Actions

  • Copy / Cut - Clipboard operations on selected text
  • Open URL - Open selected text as a URL in the default browser
  • Run Command - Run selections that begin with an installed executable in Terminal, iTerm2, Ghostty, Alacritty, Warp, kitty, or WezTerm. Commands with chaining, substitution, redirection, or multiple lines require confirmation.

Web Search

Search selected text with 7 built-in engines:

  • Google, Bing, DuckDuckGo, Baidu, Sogou, 360 Search, Yandex
  • Custom URL scheme or URL template using {{query}} (for example myapp or https://example.com/search?q={{query}})

Word Lookup

  • System Dictionary - macOS built-in dictionary
  • Eudic - Launch Eudic with the selected word
  • Custom App - Open any dictionary app via URL scheme

Translation

  • App-based - Bob (via AppleScript), Eudic (via URL scheme)
  • LLM-based - Translate using any configured LLM provider with 27 target languages including English, Chinese (Simplified/Traditional), Japanese, Korean, Spanish, French, German, and more
  • DeepL - API-based translation

Text-to-Speech

  • System - Apple's built-in AVSpeechSynthesizer with multiple voices and languages
  • ElevenLabs - High-quality API-based TTS with multiple models (v3, Turbo v2.5, Flash v2.5, Multilingual v2) and custom voice selection

Chat

Chat with AI about selected text in a floating panel with streaming responses and rich Markdown rendering.

  • Source context awareness — the AI can read the source file (line-range) or web page (character-range) for deeper understanding
  • Supports PDF files via PDFKit text extraction
  • Tool calling with user approval before reading source content
  • Copy or apply AI responses directly to the original selection
  • Pinnable panel that persists across interactions
  • Local session history with a configurable retention limit and controls to delete individual sessions or clear all history

Grammar Check

Check spelling, grammar, punctuation, and clarity in the text's original language, including mixed-language passages. Choose British English, American English, or accept both conventions.

Configure a provider and optional model override under Settings > Grammar, then choose Hotkey only or Automatic + hotkey. Record a shortcut to check selected text, or the current paragraph of the focused input box when nothing is selected (on a blank line, the paragraph above the caret). Automatic mode checks the current paragraph after a typing pause and shows an issue indicator. Input boxes in Electron apps such as Slack, Obsidian, and VS Code are supported.

Suggestions are underlined in the source text, like Grammarly: red for correctness, blue for clarity, purple for tone. Click an underline to open the review at that suggestion without leaving the editor; hovering a suggestion in the review highlights its text. Turn this off under Settings > Grammar.

Review suggestions before accepting individual changes or applying all of them. The panel offers Grammar only, Improve clarity, and Rewrite, with optional Formal or Casual tone. Manual checks remember these choices; automatic checks preserve your tone and use grammar and clarity suggestions. Rewrite shows a full-text preview with an Original comparison.

The review stays open when you edit the source and offers Recheck before any further changes can be applied. Undo restores the latest verified application while the source is unchanged; starting a new check or changing the writing profile clears this one-level undo state.

Checks are limited to 8,000 characters. When Accessibility exposes a selection without a writable text range, results can be copied instead. Copy-based capture uses the existing per-app Clipboard Fallback opt-in and only runs on a manual check.

Custom LLM Actions

5 built-in prompt templates, plus support for creating your own:

  • Polish, Extract Actions, Summarize, Bulletize, Draft Email

Each action can output to a result window or edit text inline. LLM actions can optionally include bounded source context from the current file, PDF, or web page using {{CONTEXT}}, {{SOURCE_URL}}, {{APP_NAME}}, and {{BUNDLE_ID}}.

Custom JavaScript Actions

7 starter templates with JavaScriptCore execution, including async fetch support for HTTP/HTTPS requests:

  • Title Case, URL Toolkit, JWT Decode, Format JSON, Convert Timestamps, Clean Up Escapes, Wrap as Quote

Scripts run in a separate helper process (Contents/Helpers/selectionbar-js-helper), so a script that never terminates is killed at its deadline instead of tying up SelectionBar. If the helper is missing, execution falls back to running in-process.

Pipelines

Chain existing JavaScript and LLM actions into an ordered workflow. Each step receives the previous step's output, allowing reusable actions to be composed without duplicating scripts or prompts.

Key Binding Actions

Create shortcut actions in Actions > Built-in > Key Bindings to trigger app commands directly (for example cmd+b for Bold).

  • Add multiple shortcut actions with custom names and icons
  • Configure per-app shortcut overrides by bundle ID
  • Built-in starters: Bold, Italic, Underline

App Profiles

Create per-app action profiles that replace the global custom-action list for a specific application. Profiles can select and reorder any configured key-binding, JavaScript, LLM, or pipeline action.

Do Not Disturb

Require a modifier key (Option, Command, Control, or Shift) to activate the toolbar. Prevents the toolbar from appearing during normal text selection.

Other

  • Ignored Apps - Exclude specific applications from text selection monitoring
  • Clipboard Fallback - Opt specific apps into a stricter copy-based selection fallback when Accessibility does not expose selected text; installed copies of WeChat and Telegram are prefilled
  • Launch at Login - Auto-start SelectionBar on login
  • Auto-Updates - Built-in update checking via Sparkle
  • App Language - Follow the system language or select English, Japanese, Simplified Chinese, or Traditional Chinese

Requirements

  • macOS 14.0 (Sonoma) or later
  • Accessibility permission (to read and edit selections)
  • Input Monitoring permission (to observe global mouse and keyboard events)
  • Automation permission (optional, for browser page reading and app-specific integrations)

Building from source currently requires Xcode 26 with Swift 6.2 or later because the PermissionFlow dependency uses Swift tools version 6.2.

Installation

Download

Grab the latest signed build from the releases page, open the DMG, and drag SelectionBar.app into /Applications. The app updates itself via Sparkle after that.

Build from Source

git clone https://github.com/tacshi/SelectionBar.git
cd SelectionBar
./scripts/build-debug.sh
open SelectionBar.app

Usage

  1. Launch the app - SelectionBar appears in the menu bar
  2. Grant Accessibility and Input Monitoring permissions when prompted
  3. Select any text in any application
  4. A floating toolbar appears with action buttons
  5. Click an action to process the selected text

Do Not Disturb Mode

Select text, then hold the configured modifier key to show the toolbar. You can also hold the key while selecting text. Once shown, the toolbar stays open when you release the key so you can choose an action.

Troubleshooting

The toolbar never appears

SelectionBar reads selections through the Accessibility API and detects selection gestures using global event monitors. Both Accessibility and Input Monitoring are required; macOS may silently suppress either API when its permission is missing.

  1. Open SelectionBar > Settings > General > Permissions and check both statuses.
  2. In System Settings > Privacy & Security, make sure SelectionBar is enabled under both Accessibility and Input Monitoring.
  3. If either permission is already enabled but the app still does nothing, toggle it off and on again. Permission grants can become stale after an update or local rebuild changes the app binary.
  4. Quit and relaunch SelectionBar after changing Input Monitoring permission.

Check Ignored Apps in settings too: the toolbar is suppressed in any app listed there, and in password fields (macOS blocks synthetic events while secure input is active).

The toolbar appears but shows no text in some apps

A few apps (Electron and Java-based ones especially) do not expose selections through the Accessibility API. For those, add the app under Clipboard Fallback in settings — SelectionBar will synthesize a copy and restore your clipboard afterwards.

AI actions fail with an HTTP error

Confirm the provider's API key is saved (Providers tab, use Test Connection) and that the model ID is one your account can reach. For custom OpenAI-compatible endpoints, the base URL must include the version path, e.g. https://example.com/v1.

Supported Providers

Provider Capabilities Setup
OpenAI LLM, Translation, Chat API key required
OpenRouter LLM, Translation, Chat API key required
DeepL Translation API key required
ElevenLabs Text-to-Speech API key required
Custom OpenAI-compatible LLM, Translation, Chat Choose a provider preset or enter an OpenAI-compatible base URL and credential

Architecture

SPM package with four targets:

  • SelectionBarApp - SwiftUI menu bar app, settings UI, provider configuration
  • SelectionBarCore - Core library with selection monitoring, action handling, floating toolbar, chat
  • SelectionBarJavaScriptEngine - JavaScriptCore execution engine, shared by the app and the helper
  • SelectionBarJSHelper - One-shot child process that runs a single JavaScript action and exits

Data Flow

  1. SelectionMonitor detects text selection via Accessibility API
  2. SelectionBarCoordinator shows the floating SelectionBarView
  3. User clicks an action → SelectionBarActionHandler processes it
  4. Results are displayed in SelectionResultView, replaced inline, or shown in ChatPanelView

Tech Stack

  • Swift 6 / SwiftUI
  • @Observable (Observation framework)
  • macOS Accessibility APIs
  • PermissionFlow (Accessibility and Input Monitoring setup)
  • JavaScriptCore (custom JS actions)
  • MarkdownUI (chat response rendering)
  • PDFKit (PDF text extraction)
  • Sparkle (auto-updates)
  • Keychain Services (secure credential storage)

Localization

English, Japanese, Simplified Chinese, Traditional Chinese (including Hong Kong and Taiwan system language preferences).

Contributing

Issues and pull requests are welcome. Before opening a PR:

xcrun swift-format lint --recursive --strict Sources Tests Package.swift
swift build
swift test
bash scripts/test-resource-packaging.sh

The packaging check loads app and dependency resources from a relocated, signed fixture app with its SwiftPM build directory unavailable.

CI runs these checks on macOS 26 for every pull request. To apply formatting locally before running the checks:

xcrun swift-format --recursive --in-place Sources Tests Package.swift

License

MIT

About

A macOS menu bar app for instant text processing, translation, lookup, and web search on any selected text

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages