lacona-api
Cross-platform API for use with Lacona commands
Environment Detection
isOSX
isOSX -> Boolean
Returns true
if the system is running on Mac OSX.
isDemo
isDemo -> Boolean
Returns true
if the system is running in a Demo environment.
Javascript Helpers
The Lacona Javascript execution environment does not include a few common JS features - Lacona reimplements them.
setTimeout
-> Any
Calls done
after ms
ms.
Returns an opaque value which can be passed to clearTimeout
.
clearTimeout
Cancels a timeout started by setTimeout
.
Low-level functions
Use these for implementing new functionality that is not provided by lacona-api. If you have functionality that you believe would be useful to other commands, please open an issue and work toward adding it to the core - that will provide improved performance and reliability across platforms.
runApplescript
Run script
as an applescript script. Any value returned will be exported
as a JSON object and provided to done
.
======= This function does nothing if run on non-OSX environments.
fetchSpotlight
-> Promise<Array<Object>>=======
Queries Spotlight once and closes the query. Returns an Promise.
watchSpotlight
-> Observable<Array<Object>>
Queries Spotlight, and returns an Observable, which emits the entire query results everytime new data is found.
Cancels the query when unsubscribed.
callNode
No longer used, as all Lacona commands now have access to a full node.js environment
callSystem
No longer use - use child_process
instead
showNotification
Displays an OS notification (using Notification Center, on OSX).
fetchUserDefaults
Fetch system defaults. If no key
is provided, it will fetch an Object
representing the entire domain. Equivalent to using defaults read
.
Opening Things
openURL
-> void
Opens a given URL (with a protocol) in the default handler.
openFile
-> void
Opens a given file in the default handler. Leading ~
will be expanded.
Working with Applications
fetchApplications
-> Observable<name: String bundleId: String>
Creates a live spotlight query for Applications - recursively
searching the given directories
, and adding the apps at appPaths
launchApplication
openURLInApplication
openFileInApplication
bundleIdForApplication
-> String
Syncronously returns the Bundle ID for a given application name.
bundleIdForApplication({name: "Safari"}) === "com.apple.safari"
Contacts, Calendars, and Reminders
createEvent
Creates an event on the default calendar. Calls done
with an error or nothing.
createReminder
-> void Creates a reminder on the default list Calls `done` with an error or nothing ### fetchUserContact ```jsfetchUserContact(Callback<Object>)
Returns the contact that the user has set as their own.
fetchContacts
Returns all contacts on the system ## Working with Bookmarks ### fetchBookmarks ```jsfetchBookmarks() -> Observable<{name:String, url: String}>
Creates a live spotlight query for Bookmarks. url
can be opened using
openUrl({url})
.
Working with Files
searchFiles
-> Observable<path: String contentType: String>
Creates a non-live spotlight query that searches filenames for a given string. This search is case- and diacritic-insensitive. It does not search applications, system files, bookmarks, contacts, browser history, calendar events, or chat transcripts.
fetchDirectoryContents
Returns the contents of a given directory.
userHome
-> String
Returns the user's home directory.