#
hs.sharing
Share items with the macOS Sharing Services under the control of Hammerspoon.
This module will allow you to share Hammerspoon items with registered Sharing Services. Some of the built-in sharing services include sharing through mail, Facebook, AirDrop, etc. Other applications can add additional services as well.
For most sharing services (this has not been tested with all), the user will be prompted with the standard sharing dialog showing what is to be shared and offered a chance to submit or cancel.
This example prepares an email with a screenshot:
mailer = hs.sharing.newShare("com.apple.share.Mail.compose")
mailer:subject("Screenshot generated at " .. os.date()):recipients({ "[email protected]" })
mailer:shareItems({ [[
Add any notes that you wish to add describing the screenshot here and click the Send icon when you are ready to send this
]], hs.screen.mainScreen():snapshot() })
Common item data types that can be shared with Sharing Services include (but are not necessarily limited to):
- basic data types like strings and numbers
- hs.image objects
- hs.styledtext objects
- web sites and other URLs through the use of the
hs.sharing.URL function - local files through the use of file URLs created with the
hs.sharing.fileURL function
#
API Overview
Constants - Useful values which cannot be changed
builtinSharingServices
Functions - API calls offered directly by the extension
fileURL shareTypesFor URL
Constructors - API calls which return an object, typically one that offers API methods
newShare
Methods - API calls which can only be made on an object returned by a constructor
accountName alternateImage attachments callback canShareItems image messageBody permanentLink recipients serviceName shareItems subject title