đź“–   Chapter 18

All the APIs!

Learn about every API that Hammerspoon offers, and get inspired.

Next Chapter

In this final chapter, I’ll list every single Hammerspoon API along with some ideas of what you could use it for. You can combine any of these APIs for even more powerful scripts.

hs #

docs

Core Hammerspoon functionality

hs.alert #

docs

Simple on-screen alerts

hs.appfinder #

docs

Easily find hs.application and hs.window objects

hs.applescript #

docs

Execute AppleScript code

hs.application #

docs

Manipulate running applications

hs.application.watcher #

docs

Watch for application launch/terminate events

hs.audiodevice #

docs

Manipulate the system’s audio devices

hs.audiodevice.datasource #

docs

Inspect/manipulate the data sources of an audio device

hs.audiodevice.watcher #

docs

Watch for system level audio hardware events

hs.axuielement #

docs

This module allows you to access the accessibility objects of running applications, their windows, menus, and other user interface elements that support the OS X accessibility API.

hs.axuielement.axtextmarker #

docs

This submodule allows hs.axuielement to support using AXTextMarker and AXTextMarkerRange objects as parameters for parameterized Accessibility attributes with applications that support them.

hs.axuielement.observer #

docs

This submodule allows you to create observers for accessibility elements and be notified when they trigger notifications. Not all notifications are supported by all elements and not all elements support notifications, so some trial and error will be necessary, but for compliant applications, this can allow your code to be notified when an application’s user interface changes in some way.

hs.base64 #

docs

Base64 encoding and decoding

hs.battery #

docs

Battery/power information

hs.battery.watcher #

docs

Watch for battery/power state changes

hs.bonjour #

docs

Find and publish network services advertised by multicast DNS (Bonjour) with Hammerspoon.

hs.bonjour.service #

docs

Represents the service records that are discovered or published by the hs.bonjour module.

hs.brightness #

docs

Inspect/manipulate display brightness

hs.caffeinate #

docs

Control system power states (sleeping, preventing sleep, screen locking, etc)

hs.caffeinate.watcher #

docs

Watch for display and system sleep/wake/power events

hs.canvas #

docs

A different approach to drawing in Hammerspoon

hs.canvas.matrix #

docs

A sub module to hs.canvas which provides support for basic matrix manipulations which can be used as the values for transformation attributes in the hs.canvas module.

hs.chooser #

docs

Graphical, interactive tool for choosing/searching data

hs.console #

docs

Some functions for manipulating the Hammerspoon console.

hs.crash #

docs

Various features/facilities for developers who are working on Hammerspoon itself, or writing extensions for it. It is extremely unlikely that you should need any part of this extension, in a normal user configuration.

hs.deezer #

docs

Controls for Deezer music player.

hs.dialog #

docs

A collection of useful dialog boxes, alerts and panels for user interaction.

hs.dialog.color #

docs

A panel that allows users to select a color.

hs.distributednotifications #

docs

Interact with NSDistributedNotificationCenter

hs.doc #

docs

Create documentation objects for interactive help within Hammerspoon

hs.doc.builder #

docs

Builds documentation support files. Still experimental.

hs.doc.hsdocs #

docs

Manage the internal documentation web server.

hs.doc.markdown #

docs

Markdown to HTML and plaintext conversion support used by hs.doc

hs.dockicon #

docs

Control Hammerspoon’s dock icon

hs.drawing #

docs

DEPRECATED. Primitives for drawing on the screen in various ways.

hs.drawing.color #

docs

Provides ccess to the system color lists and a wider variety of ways to represent color within Hammerspoon.

hs.eventtap #

docs

Tap into input events (mouse, keyboard, trackpad) for observation and possibly overriding them

hs.eventtap.event #

docs

Create, modify and inspect events for hs.eventtap

hs.expose #

docs

Keyboard-driven expose replacement/enhancement

hs.fnutils #

docs

Functional programming utility functions

hs.fs #

docs

Access/inspect the filesystem

hs.fs.volume #

docs

Interact with OS X filesystem volumes

hs.fs.xattr #

docs

Get and manipulate extended attributes for files and directories

hs.geometry #

docs

Utility object to represent points, sizes and rects in a bidimensional plane

hs.grid #

docs

Move/resize windows within a grid

hs.hash #

docs

Various hashing algorithms

hs.hid #

docs

HID interface for Hammerspoon, controls and queries caps lock state

hs.hid.led #

docs

HID LED interface for Hammerspoon, controls the state of keyboard LEDs

hs.hints #

docs

Switch focus with a transient per-application keyboard shortcut

hs.host #

docs

Inspect information about the machine Hammerspoon is running on

hs.host.locale #

docs

Retrieve information about the user’s Language and Region settings.

hs.hotkey #

docs

Create and manage global keyboard shortcuts

hs.hotkey.modal #

docs

Create/manage modal keyboard shortcut environments

hs.http #

docs

Perform HTTP requests

hs.httpserver #

docs

Simple HTTP server

hs.httpserver.hsminweb #

docs

Minimalist Web Server for Hammerspoon

hs.httpserver.hsminweb.cgilua #

docs

Provides support functions in the cgilua module for Hammerspoon Minimal Web Server Lua templates.

hs.httpserver.hsminweb.cgilua.lp #

docs

Support functions for the CGILua compatibility module for including and translating Lua template pages into Lua code for execution within the Hammerspoon environment to provide dynamic content for http requests.

hs.httpserver.hsminweb.cgilua.urlcode #

docs

Support functions for the CGILua compatibility module for encoding and decoding URL components in accordance with RFC 3986.

hs.image #

docs

A module for capturing and manipulating image objects from other modules for use with hs.drawing.

hs.inspect #

docs

Produce human-readable representations of Lua variables (particularly tables)

hs.ipc #

docs

Provides Hammerspoon with the ability to create both local and remote message ports for inter-process communication.

hs.itunes #

docs

Controls for iTunes music player

hs.javascript #

docs

Execute JavaScript code

hs.json #

docs

JSON encoding and decoding

hs.keycodes #

docs

Convert between key-strings and key-codes. Also provides functionality for querying and changing keyboard layouts.

hs.layout #

docs

Window layout manager

hs.location #

docs

Determine the machine’s location and useful information about that location

hs.location.geocoder #

docs

Converts between GPS coordinates and more user friendly representations like an address or points of interest.

hs.logger #

docs

Simple logger for debugging purposes

hs.math #

docs

Various helpful mathematical functions

hs.menubar #

docs

Create and manage menubar icons

hs.messages #

docs

Send messages via iMessage and SMS Relay (note, SMS Relay requires OS X 10.10 and an established SMS Relay pairing between your Mac and an iPhone running iOS8)

hs.midi #

docs

MIDI Extension for Hammerspoon.

hs.milight #

docs

Simple controls for the MiLight LED WiFi bridge (also known as LimitlessLED and EasyBulb)

hs.mjomatic #

docs

tmuxomatic-like window management

hs.mouse #

docs

Inspect/manipulate the position of the mouse pointer

hs.network #

docs

This module provides functions for inquiring about and monitoring changes to the network.

hs.network.configuration #

docs

This sub-module provides access to the current location set configuration settings in the system’s dynamic store.

hs.network.host #

docs

This sub-module provides functions for acquiring host information, such as hostnames, addresses, and reachability.

hs.network.ping #

docs

This module provides a basic ping function which can test host availability. Ping is a network diagnostic tool commonly found in most operating systems which can be used to test if a route to a specified host exists and if that host is responding to network traffic.

hs.network.ping.echoRequest #

docs

Provides lower-level access to the ICMP Echo Request infrastructure used by the hs.network.ping module. In general, you should not need to use this module directly unless you have specific requirements not met by the hs.network.ping module and the hs.network.ping object methods.

hs.network.reachability #

docs

This sub-module can be used to determine the reachability of a target host. A remote host is considered reachable when a data packet, sent by an application into the network stack, can leave the local device. Reachability does not guarantee that the data packet will actually be received by the host.

hs.noises #

docs

Contains two low latency audio recognizers for different mouth noises, which can be used to trigger actions like scrolling or clicking.

hs.notify #

docs

This module allows you to create on screen notifications in the User Notification Center located at the right of the users screen.

hs.osascript #

docs

Execute Open Scripting Architecture (OSA) code - AppleScript and JavaScript

hs.pasteboard #

docs

Inspect/manipulate pasteboards (more commonly called clipboards). Both the system default pasteboard and custom named pasteboards can be interacted with.

hs.pasteboard.watcher #

docs

Watch for Pasteboard Changes.

hs.pathwatcher #

docs

Watch paths recursively for changes

hs.plist #

docs

Read and write Property List files

hs.redshift #

docs

Inverts and/or lowers the color temperature of the screen(s) on a schedule, for a more pleasant experience at night

hs.screen #

docs

Manipulate screens (i.e. monitors)

hs.screen.watcher #

docs

Watch for screen layout changes

hs.serial #

docs

Communicate with external devices through a serial port (most commonly RS-232).

hs.settings #

docs

Serialize simple Lua variables across Hammerspoon launches

hs.sharing #

docs

Share items with the macOS Sharing Services under the control of Hammerspoon.

hs.socket #

docs

Talk to custom protocols using asynchronous TCP sockets

hs.socket.udp #

docs

Talk to custom protocols using asynchronous UDP sockets

hs.sound #

docs

Load/play/manipulate sound files

hs.spaces #

docs

Controls for macOS Spaces. Currenly only used by hs.spaces.watcher.

hs.spaces.watcher #

docs

Watches for the current Space being changed

hs.speech #

docs

This module provides access to the Speech Synthesizer component of OS X.

hs.speech.listener #

docs

This module provides access to the Speech Recognizer component of OS X.

hs.spoons #

docs

Utility and management functions for Spoons

hs.spotify #

docs

Controls for Spotify music player

hs.spotlight #

docs

This module allows Hammerspoon to preform Spotlight metadata queries.

hs.spotlight.group #

docs

This sub-module is used to access results to a spotlightObject query which have been grouped by one or more attribute values.

hs.spotlight.item #

docs

This sub-module is used to access the individual results of a spotlightObject or a spotlightGroupObject.

hs.sqlite3 #

docs

Interact with SQLite databases

hs.streamdeck #

docs

Configure/control an Elgato Stream Deck

hs.styledtext #

docs

This module adds support for controlling the style of the text in Hammerspoon.

hs.tabs #

docs

Place the windows of an application into tabs drawn on its titlebar

hs.tangent #

docs

Tangent Control Surface Extension

hs.task #

docs

Execute processes in the background and capture their output

hs.timer #

docs

Execute functions with various timing rules

hs.timer.delayed #

docs

Specialized timer objects to coalesce processing of unpredictable asynchronous events into a single callback

hs.uielement #

docs

A generalized framework for working with OSX UI elements

hs.uielement.watcher #

docs

Watch for events on certain UI elements (including windows and applications)

hs.urlevent #

docs

Allows Hammerspoon to respond to URLs

hs.usb #

docs

Inspect USB devices

hs.usb.watcher #

docs

Watch for USB device connection/disconnection events

hs.utf8 #

docs

Functions providing basic support for UTF-8 encodings

hs.vox #

docs

Controls for VOX music player

hs.watchable #

docs

A minimalistic Key-Value-Observer framework for Lua.

hs.websocket #

docs

Simple websocket client.

hs.webview #

docs

Display web content in a window from Hammerspoon

hs.webview.datastore #

docs

Provides methods to list and purge the various types of data used by websites visited with hs.webview.

hs.webview.toolbar #

docs

Create and manipulate toolbars which can be attached to the Hammerspoon console or hs.webview objects.

hs.webview.usercontent #

docs

This module provides support for injecting custom JavaScript user content into your webviews and for JavaScript to post messages back to Hammerspoon.

hs.wifi #

docs

Inspect WiFi networks

hs.wifi.watcher #

docs

Watch for changes to the associated wifi network

hs.window #

docs

Inspect/manipulate windows

hs.window.filter #

docs

Filter windows by application, title, location on screen and more, and easily subscribe to events on these windows

hs.window.highlight #

docs

Highlight the focused window

hs.window.layout #

docs

WARNING: EXPERIMENTAL MODULE. DO NOT USE IN PRODUCTION.

hs.window.switcher #

docs

Window-based cmd-tab replacement

hs.window.tiling #

docs

WARNING: EXPERIMENTAL MODULE. DO NOT USE IN PRODUCTION.

Awesome Hammerspoon