Skip to content

Service actions

In a Service action, PopClip will invoke a macOS Service by name.

Calling a macOS Service from JavaScript

You can also call popclip.performService() from a JavaScript action.

javascript
// #popclip service js example
// name: Dated Sticky
const today = new Date().toLocaleDateString();
const note = `${popclip.input.text}\n\nClipped ${today}`;
await popclip.performService("Make Sticky", note);

Properties

A service action is defined by the presence of a serviceName field, as follows:

KeyTypeDescription
serviceNameStringThe name of the macOS service to call.

Service names

The service name is usually exactly as shown in the Services menu, for example Add to Deliveries. However, in some cases you may need to look into the Info.plist of the application to find the name defined in there under NSServicesNSMenuItem. An example of this is the Make New Sticky Note service which must be called as Make Sticky.

Input and output

The selected plain text will be sent as input to the service. If captureHtml is set to true, then the HTML version of the selected text will also be sent as input to the service.

Service actions never return any output.

Examples

Simple snippet calling a service:

yaml
#popclip
name: "Deliveries"
serviceName: "Add to Deliveries"

The following defines an extension that makes a new Stickies note from the selected text, using the Make Sticky service mentioned above. (This is the same action as the published Make Sticky extension.)

yaml
#popclip
name: Make Sticky
icon: symbol:note.text
serviceName: Make Sticky