0.9.79 - Hammerspoon/hammerspoon GitHub Wiki
What's new in 0.9.79?
Here is a summary of what's changed in Hammerspoon 0.9.79.
Improvements
Lua Updated
Hammerspoon now uses Lua 5.4.0 (as opposed to 5.3.5). It's main new features are discussed here.
If you use Luarocks, you may need to make some changes to your code, which is discussed in the Wiki.
coroutine
support
Fixed Hammerspoon fixed various things to allow coroutine
support to work properly.
You can also find more information about coroutines on the Wiki.
Crash Reporting
We now use sentry.io instead of Crashlytics for monitoring crash data.
You can review our new privacy policy here.
Stream Deck Support
hs.streamdeck
has been refactored to add support for the Stream Deck XL and Stream Deck Mini.
Other Changes
- Added ability to pass optional alert message in Spoon hotkey bindings.
- Changed
hs.watchable
to allow for anil
(or not provided) callback for cleaner watcher construction. - The
MJConfigFile
preferences option now resolves symlinks. However, please note that we may revert back to the original behaviour in a future release.
Bug Fixes
- Fixed potential memory leak in
hs.eventtap.event:getUnicodeString()
hs.chooser
now correctly shows icons in their original colors.- Fixed potential crashes due to dispatches in various modules:
hs.application
,hs.battery.watcher
,hs.caffeinate.watcher
,hs.canvas
,hs.dialog
,hs.host.locale
,hs.http
,hs.httpserver
,hs.image
,hs.keycodes
,hs.location
,hs.network
,hs.noises
,hs.screen
,hs.socket.udp
, hs.spaces.watcher,
hs.webviewand
hs.wifi`. hs.dialog.chooseFileOrFolder()
now supports filenames with space.- Fixed bug which allows sending binary data with
hs.socket.udp()
. - Fixed bug in
hs.webview.toolbar
, which could cause a delay. - Minor bug fixes to
hs.caffienate
andhs.canvas
. - Fixed a potential crash in the
hs.midi
callback. - Fixed a potential crash in
hs.settings
. - Fixed potential nil error in
hs.window.focus()
New Extensions
hs.axuielement
This extension allows you to access the accessibility objects of running applications, their windows, menus, and other user interface elements that support the macOS Accessibility API.
You can learn more here.
You can find some examples of usage here.
hs.serial
This extension allows you to communicate with external devices through a serial port (most commonly RS-232).
You can learn more here.
Here's a simple example of it's usage:
local portNames = hs.serial.availablePortNames()
local portOne = portNames and portNames[1]
if portOne then
serialPort = hs.serial.newFromName(portOne)
:baudRate(4800)
:dataBits(5)
:parity("odd")
:shouldEchoReceivedData(false)
:stopBits(1)
:usesDTRDSRFlowControl(false)
:usesRTSCTSFlowControl(false)
:callback(function(_ callbackType, message)
print(string.format("callbackType: %s", callbackType))
print(string.format("message: %s", message))
end)
:open()
end
hs.websocket
This extension allows you to create a simple websocket client. A websocket is a communications protocol, providing full-duplex communication channels over a single TCP connection. Previously you could use the undocumented hs.http.websocket
for working with websockets, however it never worked quite as expected, so this new extension replaces that.
You can learn more here.
Here's a simple example of it's usage:
echoTest = hs.websocket.new("wss://echo.websocket.org/", function(e, m)
if e == "open" then
echoTest:send("this is a test")
else
print(string.format("event: %s", e))
print(string.format("message: %s", m))
end
end)
New Features
hs.screenRecordingState()
Checks the Screen Recording Permissions for Hammerspoon, and optionally allows you to prompt for permissions.
You can learn more here.
hs.window.list()
Gets a table containing all the window data retrieved from CGWindowListCreate
. This allows you to get window information without Accessibility Permissions.
You can learn more here.
hs.pasteboard.watcher()
This extension allows you to watch for Pasteboard Changes. macOS doesn't offer any API for getting Pasteboard notifications, so this extension uses polling to check for Pasteboard changes at a chosen interval (defaults to 0.25).
You can learn more here.
Example usage:
generalPBWatcher = hs.pasteboard.watcher.new(function(v) print(string.format("General Pasteboard Contents: %s", v)) end)
specialPBWatcher = hs.pasteboard.watcher.new(function(v) print(string.format("Special Pasteboard Contents: %s", v)) end, "special")
hs.pasteboard.writeObjects("This is on the general pasteboard.")
hs.pasteboard.writeObjects("This is on the special pasteboard.", "special")
hs.relaunch()
Quits and relaunches Hammerspoon.
You can learn more here.
hs.coroutineApplicationYield()
Yield coroutine to allow the Hammerspoon application to process other scheduled events and schedule a resume in the event application queue.
You can learn more here. You can also find more information about coroutines on the Wiki.
hs.math.isNaN
Returns whether or not the value is the mathematical equivalent of "Not-A-Number".
You can learn more here.
hs.math.isFinite
Returns whether or not the value is a finite number.
You can learn more here.
hs.math.isInfinite
Returns whether or not the value is the mathematical equivalent of either positive or negative "Infinity".
You can learn more here.
hs.chooser:invalidCallback()
Sets/clears a callback for invalid choices.
You can learn more here.
hs.fs.urlFromPath()
Returns the encoded URL from a path. This is useful for supplying URLs to functions like hs.pasteboard.writeObjects({url=URL})
You can learn more here.
hs.canvas.useCustomAccessibilitySubrole()
Get or set whether or not canvas objects use a custom accessibility subrole for the contaning system window.
You can learn more here.