Launch System Settings with macOS Ventura using Hammerspoon
So, Hammerspoon is a thing.
I’m trying it out a bit. I didn’t at first realize how this brand of LUA works, since it seems to be different from the Renoise API LUA code.
But I got this working:
hs.hotkey.bindSpec({ { "shift", "cmd"}, "," },
function()
hs.application.launchOrFocus("System Settings")
end
)
This takes your regular Shift-CMD-, and boots up System Settings — and in case it is already running, brings the focus to that.
I didn’t quite yet dig deeper into whether a specific page of System Settings could be brought up, as that would be pretty good, but there’s always next time, right?
No. The time is now. So, there’s a really useful page, which lets you find some additional deeplinks for System Settings, and therefore, this, brings you to Software Update:
open "x-apple.systempreferences:com.apple.Software-Update-Settings.extension"
Now, the real question is, what’s the method for Hammerspoon to boot up these types of deeplinks? Cos it isn’t hs.application.launchOrFocus.
.. Ok, after a very frustrating evening, decided to call it a night and switch approaches. First try and make it work with AppleScript.
This works in AppleScript:
tell application "System Settings"
activate
end tell
tell application "System Settings"
reveal pane id "com.apple.Software-Update-Settings.extension"
end tell
Not sure why it needs two tells, but at least it works. Well, here’s how it looks like with Hammerspoon. For some reason, this is very slow!
hs.hotkey.bindSpec({ { "ctrl", "cmd", "alt"}, "," },
function()
hs.osascript.applescript([[tell application "System Settings" to reveal pane id "com.apple.Software-Update-Settings.extension"
tell application "System Settings" to activate]])
end
)
If anyone knows how to make this faster, please let me know?
EDIT: This is how you get it to be faster:
hs.hotkey.bindSpec({ { "ctrl", "cmd", "alt"}, "," },
function()
local url = 'x-apple.systempreferences:com.apple.Software-Update-Settings.extension'
local handler = 'com.apple.systempreferences'
hs.urlevent.openURLWithBundle(url, handler)
end
)
The advice was provided in this comment in this ticket: https://github.com/Hammerspoon/hammerspoon/issues/3457#issuecomment-1503588230
Thanks everyone!