Repository navigation
Releases
Hammerspoon 2 1.0.0 Beta 1
Added
- Spaces support on screens:
screen.spaces,screen.currentSpaceandscreen.addSpace(), plushs.screen.allSpaces(),focusedSpace(),spaceForID()andspaceForUUID()(#371) HSSpace, for switching to (goto()), removing and inspecting a space and the windows on it (#371)window.spacesandwindow.moveToSpace(), which moves any app's window to another space without opening Mission Control (#371)hs.screen.on("spaceChange", ...), which reports the screen whose space changed and the spaces it changed from and to (#371)hs.screen.missionControlNames(),openMissionControl(),closeMissionControl(), and toggles for Mission Control, App Exposé, Launchpad and Show Desktop (#371)
Changed
- The documentation and the update feed have moved to https://www.hammerspoon.org/2/ (#419)
- Crash reports and the documentation's GitHub links now go to https://github.com/Hammerspoon/Hammerspoon2 (#420)
Full Changelog: 0.0.18...1.0.0-beta.1
Hammerspoon 2 0.0.18
Added
hs.screenandhs.windownow contain multiple new functions/methods for interacting with macOS Spaces- A notification when your config folder or file is missing or can't be read, with a button that opens Settings
- A notification when your config throws an error while loading, with a button that opens the Console
hs.chooseronSelectionChange, called with the row and its choice whenever the selected row changesurlproperty onhs.httpresponses, giving the final URL after any redirects- Documentation guides now have linkable section headings, and the sidebar shows an outline of the guide you're reading
- A "Finding Spoons" section in the Spoons guide
- The documentation sidebar is now a collapsible tree of every guide, module and type, so you can jump straight to any section, property or method
hs.socket.createUnixDatagram(), for sending and receiving Unix domain datagrams, e.g. from Karabiner-Elements'send_user_commandhs.consoleHistory(), which returns the messages in the Hammerspoon Console, optionally filtered by level, text, or only those logged since a previous call
Changed
- The "hs.canvas" documentation guide is now called "Canvas Tutorial"
Fixed
hs.ui.textPrompt()now puts the keyboard focus in its text field when it opens, so you can type straight away- Hammerspoon no longer crashes at launch if your config file can't be read
- Clicking a notification no longer also opens the Console when no Hammerspoon windows are open
hs.chooser.refreshChoices()no longer leavesselectedRowpointing past the last row when fewer choices match- A crash when destroying an
hs.uiwindow containing a web view from a timer or other callback
Full Changelog: 0.0.17...0.0.18
Hammerspoon 2 0.0.17
Added
HSMenuBarItem.titleColor, to colour a menu bar item's title (#354)- A
colorkey forhs.menubarandhs.dockiconmenu entries, to colour their titles (#354) hs.bluetooth, for listing paired and connected Bluetooth devices, their battery levels, connecting and disconnecting them, scanning for nearby devices, reading and writing Bluetooth LE characteristics, and watching for connections and Bluetooth being turned on or off (#357)hs.permissions.checkBluetooth()andhs.permissions.requestBluetooth()(#357)- Hammerspoon 2 can now request access to calendars and reminders, so scripts can read them via EventKit (e.g. JXA in
hs.osascript, or tools run withhs.task) (#362) HSUIWindow.behavior()andHSUIWindow.behaviorList(), to make a window appear on every Space or over fullscreen apps (e.g.behaviorList(["canJoinAllSpaces", "fullScreenAuxiliary"])) (#364)hs.choosernow supports Page Up / Page Down (or Fn-↑ / Fn-↓) to move through results a page at a time, and Home / End (or Fn-← / Fn-→) to jump to the first / last result (#369)hs.wifi.configuration()andhs.wifi.cachedScanResults(), which return the configuration and cached scan results that used to be part ofhs.wifi.interfaceDetails()(#370)hs.spoons.use(), which installs a Spoon from a GitHub repository or zip URL if it isn't installed, then loads and configures it, like v1's SpoonInstall (#372)hs.spoons.install(),hs.spoons.update(),hs.spoons.uninstall(),hs.spoons.available()andhs.spoons.installed(), for managing Spoons from GitHub repositories or zip URLs (#372)- An "Install Spoons when opened" setting in the Advanced settings tab that turns off automatic installation of double-clicked
.spoon2bundles (#373) hs.chooserchoices can opt out of the context menu withcontextMenu: falsehs.socket, for communicating over raw TCP, UDP and Unix domain socketsHSSocket.enableServerTLS()andHSSocket.enableServerTLSFromKeychain(), which make a listening socket use TLS with a certificate from a PKCS#12 file or the keychainHSSocket.listen()andHSUDPSocket.bind()take an optional local IP address, to accept connections or datagrams on just that addressHSSocket.state,HSSocket.connectTimeoutandHSSocket.readTimeout, and an optionallossyargument tohs.socket.decodeText()hs.mqtt, an MQTT client for publishing and subscribing to brokers- Hammerspoon 2 offers to report a crash as a GitHub issue the next time it launches
Changed
HSUIWindow.level()andHSUIWindow.windowTitle()now update a window that's already shown (#364)hs.wifi.interfaceDetails()no longer includesconfigurationorcachedScanResults, because fetching them leaks memory inside macOS. Usehs.wifi.configuration()andhs.wifi.cachedScanResults()instead (#370)hs.loadSpoon()is nowhs.spoons.load(), and its errors have acode(#372)- Console results are now formatted like
console.log()output (e.g. booleans print astrue/false, objects as{ a: 1 }) (#378) hs.choosercontext menus are now set once for the whole chooser withcontextMenu, and report the picked entry and row to a singleonContextMenuSelectcallback, instead of each choice having its owncontextMenuwith anactionper entry
Fixed
HSWindow.isFocusednow returns true for the focused window (#358)console.log()of Hammerspoon objects (e.g. anHSApplication) printedundefined {}instead of a description of the object (#359)hs.window:focus()now keeps the requested window in front in applications such as Google Chrome that bring their previous window back after activating (#361)HSCanvas.behaviorList()andHSCanvas.behaviorValue()no longer crash Hammerspoon when given mutually exclusive behaviors (e.g.canJoinAllSpaceswithmoveToActiveSpace) or a negative bitmask; they throw an Error instead (#364)- Reloading the configuration no longer leaks the previous JavaScript environment's memory if
fetch()was used (#366) - Polling
hs.wifi.interfaceDetails()no longer makes Hammerspoon's memory use grow steadily (#370) - Errors in Promises that nothing handles, such as a Spoon that fails to load in
hs.spoons.use(), are now logged to the Console instead of disappearing (#372) - Hammerspoon could freeze when updating an
hs.chooser's choices while its callbacks were being garbage collected (#376) hs.timer.doAt()now repeats atrepeatIntervalinstead of only firing once
Full Changelog: 0.0.16...0.0.17
Hammerspoon 2 0.0.16
Added
hs.dockicon.setMenu(), which adds extra items to the menu of Hammerspoon's Dock icon, from an array of menu items or a function called each time the menu opens (#334)hs2 --version, and hs2 now warns at startup if the running Hammerspoon 2 is a different build (#335)require("node:sqlite"), an implementation of Node's synchronous SQLite API (DatabaseSync/StatementSync) using the SQLite that ships with macOS, replacing v1'shs.sqlite3(#339)hs.eventtap.keyStroke(mods, key, app)sends a keystroke with modifiers to a specific application, even in the background, without activating it (#350)hs.eventtap.makeKeyEvent()andhs.eventtap.makeKeyEventWithCode()take an optional array of modifier names (#350)
Changed
- Hammerspoon 2 now requires macOS 27 or later (#330)
hs.osascriptasync scripts now run in parallel, so their promises resolve in completion order; chain them if you need strict ordering (#330)- The
hs.ipcbroker now exits shortly afterhs.ipcstops or Hammerspoon 2 quits, instead of lingering for a minute (#335) HSApplication.titlehas been renamed toHSApplication.name(#341)HSAXElement.setAttributeValue()andperformAction()now throw anErrorsaying why the Accessibility API refused the change (with the AX error name inerr.code), instead of returningfalse(#349)HSEventTapEvent.flagscan now be set, e.g.event.flags = ["cmd", "shift"](#350)
Fixed
- A slow or stuck
hs.osascriptscript no longer delays every other script until it finishes (#330) - HSFont.custom() and HSFont.system(size, weight) are now callable under their documented names (they were customSize() and systemWeight()) (#338)
- hs.ui.webview's evalJSResult() and hs.fs.setTags(), addTags() and removeTags() now appear in the documentation (#338)
- After updating Hammerspoon 2,
hs.ipcno longer keeps talking to the IPC broker from the previous version (#335) JSON.stringify()of geometry objects (HSPoint,HSSize,HSRect),HSColor, screens, windows, applications, audio devices, Bonjour services, MIDI devices and OCR results now includes their values instead of producing{}(#340)setAttributeValue()on anhs.axelement now throws an error naming the expected type (e.g.HSPointforAXPosition) instead of silently returning false when given the wrong kind of value (#342)- hs2 no longer mixes its greeting and connection notices into stdout when input is piped or redirected, so its output can be used directly in scripts (#343)
hs.window.allWindows(),hs.window.windowsForApp()andapp.allWindowsnow include windows in native fullscreen and on other Spaces (see the docs for one limitation) (#351)hs.window.windowsForApp(null)returns an empty array instead of crashing (#351)
Full Changelog: 0.0.15...0.0.16
Hammerspoon 2 0.0.15
Added
- hs.eventtap now supports system key events (volume, brightness, media, etc)
- hs.ui.webview pages can now send messages back into your JS config
- hs.canvas can now fade canvases when showing/hiding/destroying
- App updating is now implemented
- HSAudioDevice objects now support isInUse and jackConnected
- hs.eventtap.isSecureInputEnabled() and secureInputPID()
Changed
- Functions/Methods that claim to return null now actually return null instead of undefined
- hs.ax watchers will now be automatically destroyed when the elements they are watching, are destroyed
- hs.ui's show() now orders a window to the front if it is called on an already open window
- hs.httpserver request callback now receives query parameters as an argument
- hs.hashing is now properly documented as hs.hashing rather than hs.hash
- hs.midi can now open individual ports of a multi-port device
- HSImage.copyImage() has been renamed to HSImage.duplicate()
- hs.hotkey modals can now be created without a hotkey
- hs.canvas minimumTextSize() can not be used without an existing element
- HSColor objects can now be created with hex strings, colour names and more.
- hs.canvas roundedRectRadii can now be specified with different X and Y radii
Fixed
- hs.ui's show() method no longer recreates the window every time it is called
- hs.canvas' destroy() method now destroys its entire element tree, to avoid slow memory recovery
New Contributors
- @blagerweij made their first contribution in #285
Full Changelog: 0.0.14...0.0.15
0.0.14
IMPORTANT NOTE
This pre-release includes a significant change to the way some Hammerspoon objects are garbage collected by JavaScript.
If an object is "running" or "active" in some way, such as a hotkey or a watcher, you no longer need to hold a reference to it yourself, it will remain alive until it completes its work or is otherwise destroyed.
It is likely that this has introduced some new bugs - please report them as issues here.
Added
- Documentation now includes a guide for using TypeScript for your configuration
hs.fsnow offers API for opening/reading/writing files
Changed
hs.hotkeyhotkeys now remap themselves when keyboard layout changes, so they remain consistent.on()watchers now reject invalid event nameshs.canvasobjects can now receive right mouse clickshs.window.focus()no longer raises all windows of an applicationhs.taskspawned processes are reaped more enthusiastically when terminatedhs.menubaritems can now receive middle/right/other mouse clicks
Fixed
hs.ipcand thehs2command line tool now actually workhs.choosershadows no longer clip to a rectangular shape
0.0.13
IMPORTANT NOTE
This pre-release brings a considerable refactor of the APIs for watchers/callbacks. If you are using any watchers in your config, it will break. Please see the docs for each module, to see what its replacement API is.
CHANGELOG
Added:
hs.windowcan now generate snapshots (ie screenshots of single windows)util.inspect()- A "Console" tab in Settings
hs.choosernow supports theming
Changed:
hs.axcan now watch arbitrary AX elements, rather than just applicationshs.hotkey.bind()can now accept a repeat callback at creation- Console Window again supports multi-line text selection
- Almost all "watchers" are now using a common API style of
.on()/.off()/.once()
Fixed:
hs.hotkey.bind()now raises an error if no callbacks have been suppliedhs.window.allWindows()/orderedWindows()no longer attempt to fetch windows for background processeshs.power.lockScreen()should now function correctlyhs.ui.window().video()no longer crashes on.show()hs.axwatcher now actually works
0.0.12
Added
- hs.streamdeck
- hs.canvas
- Simple onboarding UI
- Async variant of hs.eventtap.keyStrokes()
- hs.screen now has a watcher for display configuration changes
- hs.geometry methods from v1 are now present on corresponding basic types (HSRect, HSPoint, HSSize)
- fetch()
- There is now an advanced setting for enabling garbage collection logging, if you're trying to track down a memory leak issue
- HSHotkey objects now support "repeat" events when a key is being held down
- Ctrl-N and Ctrl-P can now be used to navigate through the results list in an hs.chooser window
- The first 10 results in an hs.chooser window now have keyboard shortcuts
Changed
- require() no longer simply reads and evaluates JS files. It is now a CommonJS compatible module loader
- loaded Spoons are now exposed via hs.spoons
- The included command line binary is now named hs2 rather than hs, to avoid conflicting with a HS v1 install
- hs.timer methods now support chaining
Fixed
- Various functions in hs.window are now actually bound to the hs.window object and can thus be used
- hs.camera watcher is no longer incorrectly garbage collected shortly after initialisation
- hs.audiodevice watcher is no longer incorrectly garbage collected shortly after initialisation
- hs.eventtap.keyStroke/keyStrokes are no longer affected by modifier keys being held down on a keyboard
- Improved performance of hs.window.allWindows() and visibleWindows()
- Improved hs.osascript performance by caching connection to the XPC helper
0.0.10
Added
hs.sharinghs.keyboardHSUIWindownow has callback support foronShow(),onHide()andonDestroy()
Changed
hs.ui.alertnow stack vertically if multiple are visible, except if they have been manually positionedHSUIWindow.close()is now.destroy()
Fixed
0.0.9
Added:
- hs.sound
- hs.network
- hs.fs volume features
- hs.fs xattr features
- hs.fs path watching features
- hs.screen can now read ambient light sensor data on supported (ie Apple) displays
- hs.shortcuts
- hs.mouse
- hs.plist
- hs.userdefaults (equivalent to hs.settings from v1)
- hs.wifi
- hs.locale
- most functionality from v1's hs.host is now in hs.appinfo and hs.locale
- hs.serial
- hs.midi
- hs.ui can now display videos as well as images
Changed:
- hs.location no longer using deprecated methods for geolocation
- hs.hotkey modals are now implemented in pure JS to avoid garbage collection issues
Fixed: