A lightweight clipboard-to-Ollama bridge for macOS. Copy a prompt, get an AI response — right in your clipboard.
- Copy text starting with
//ollama(e.g.,//ollama explain quantum physics) - Wait a moment while ClipLLM sends your prompt to Ollama.
- Paste — the AI response is now in your clipboard!
You can run ClipLLM using either Python or Java. Both do the same thing, but have different setups.
Best if you prefer working with scripts and the requests library.
Setup:
# Create a virtual environment and install dependencies
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtRun:
source venv/bin/activate
python clipllm.pyBest for a "zero-dependency" experience. It uses pure Java 11+ features.
Setup: No installation needed! Just make sure you have a JDK installed.
Run:
# Compile and run in one step
java ClipLLM.java- Ollama installed and running — ollama.com
- Model pulled:
ollama pull gemma4:e4b ollama pull nemotron-3-nano:4b
- Ollama serving: Make sure the Ollama app is open or run
ollama serve.
| Variable | Default | Description |
|---|---|---|
PRIMARY_MODEL |
gemma4:e4b |
The main high-quality model |
FALLBACK_MODEL |
nemotron-3-nano:4b |
Faster model used if the primary fails |
TRIGGER |
//ollama |
Text prefix that triggers a prompt |
POLL_INTERVAL |
500ms |
How often to check the clipboard |
| Feature | Python Implementation | Java Implementation |
|---|---|---|
| Clipboard | subprocess -> pbpaste/pbcopy |
java.awt.Toolkit (Native API) |
| HTTP Client | requests (External Lib) |
java.net.http.HttpClient (Native) |
| JSON Safety | Manual String replace | escapeJson() helper function |
| Concurrency | time.sleep() |
Thread.sleep() |
| Dependencies | 1 (requests) |
0 (Zero!) |
While the Python version is easy to write, the Java version is more powerful because it talks to the macOS system directly using the java.awt library, and it doesn't need any pip install to work.
Both versions use a Thread Sleep. This is crucial for your CPU's health. Instead of checking the clipboard millions of times per second (which would make your Mac hot), the program "naps" for 500ms between checks, keeping your CPU usage near 0%.
| Problem | Solution |
|---|---|
| "Cannot connect to Ollama" | Run ollama serve or open the Ollama app. |
| "Model not found" | Run ollama pull gemma4:e4b. |
| "Slow responses" | The app will automatically try the Fallback model if it takes too long. |
| "Nothing happens" | Ensure your copied text starts exactly with //ollama (with the space). |