Skip to content

Remote Control Interface

The Control API lets external programs drive Torchsnap over a local Unix domain socket. Show and hide the launcher, set the search query, check visibility state — all from shell scripts, automation tools, or custom integrations.

The Control API is disabled by default. To enable it, open Settings and toggle Control API on under the Advanced section in General.

General settings showing the Control API toggle under the Advanced section General settings showing the Control API toggle under the Advanced section

Once enabled, Torchsnap opens a Unix domain socket that accepts connections immediately. Turning the toggle off closes the socket and disconnects all active clients.

The socket is located in the Torchsnap application data directory:

Platform Path
macOS ~/Library/Application Support/app.torchsnap/control.sock
Linux ~/.local/share/app.torchsnap/control.sock

The Linux path follows the XDG Base Directory specification and respects a custom $XDG_DATA_HOME if set.

Connect with any tool that speaks Unix sockets. The examples below use socat, available via Homebrew (brew install socat) or most Linux package managers.

Terminal window
socat - UNIX-CONNECT:"$HOME/Library/Application Support/app.torchsnap/control.sock"

Type JSON-RPC requests line by line. Press Ctrl+D to disconnect.

Terminal window
SOCK="$HOME/Library/Application Support/app.torchsnap/control.sock"
echo '{"jsonrpc":"2.0","id":1,"method":"status"}' | socat - UNIX-CONNECT:"$SOCK"
# → {"id":1,"jsonrpc":"2.0","result":{"visible":false}}

The Control API uses JSON-RPC 2.0 over newline-delimited JSON:

  • Each request is a single JSON object on one line, terminated by \n.
  • Each response is a single JSON object on one line, terminated by \n.
  • The client picks an id (string or number); the server echoes it back so requests and responses can be matched.
{"jsonrpc": "2.0", "id": 1, "method": "show"}
{"jsonrpc": "2.0", "id": 2, "method": "query", "params": {"text": "firefox"}}

Success:

{"jsonrpc": "2.0", "id": 1, "result": {"ok": true}}

Error:

{"jsonrpc": "2.0", "id": 1, "error": {"code": -32601, "message": "Method not found: foo"}}

The socket supports multiple simultaneous connections. Each client operates independently as there is no shared state between connections beyond the launcher itself.

See Commands for the full list of available methods, parameters, and error codes.