Macotron

macotron.share

Open the macOS share menu for files, text or a link, or send files straight to AirDrop.

macotron.command("Share Text", "Share the clipboard text", () => {
  const text = macotron.clipboard.text();
  if (!text) return macotron.notify.toast("Share", "Clipboard is empty");
  macotron.share.open({ text });
});

Sharing

open(opts: { files?: string[]; text?: string; url?: string }): boolean

Brings Macotron forward and opens the share menu at the pointer, with every item you pass: the files, the text and the URL. The user picks a service, such as Mail, Messages or AirDrop. File paths can start with ~.

Returns false when there is nothing to share: no files, empty text, and no URL that parses. Otherwise it returns true once the menu is open, whether or not the user picks a service.

airDrop(paths: string[]): boolean

Opens the AirDrop window with these files, skipping the share menu. Paths can start with ~. Returns false when paths is empty or not an array, or when AirDrop is not available on this Mac.

macotron.share.airDrop(["~/Desktop/photo.heic"]);

See also