Anyone here using Hammerspoon? Can it do anything Keyboard Maestro can’t?
Seems like a really cool scripting language for MacOS!
The major difference here is that Keyboard Maestro has a GUI (is drag and drop) while HammerSpoon seems to be purely code from my quick glance.
Based on that, I would say it can do just about everything Keyboard Maestro could do but requires that you have a deeper understanding when it comes to logic and coding
Hi, I am not a Keyboard Maestro user, but I think it cannot create menubar entries, while Hammerspoon can.
I am using hammerspoon quite a bit. The only time I wished I had Keyboard Maestro was the image recognition to automate clicking a button (whose functionality didn’t have a menubar item).
Otherwise they are pretty similar in functionality (I think). Like @Dillon_Carter said, hammerspoon is purely code, while keyboard Maestro is mainly graphical with the ability to execute code.
My entry to hammerspoon was the desire to create a hyperkey, which gives you another (or more) layer of keyboard shortcuts. If you’re interested check out Brett Tepstra‘s version, and then google some. I don‘t need Karabiner, for example, and there are a lot of quite elaborated setups.
Nope. Keyboard Maestro is the observable universe. It’s everything we’ve ever conceived of seeing. Hammerspoon is that plus the stuff that light hasn’t had sufficient time to travel for us to know it’s there. (Objective-C and Swift are dark matter and dark energy in this weird analogy.)
Could you be a little more, uh, concrete? I’m reluctant to invest the time and effort in learning a fairly obscure language unless I have a better idea of the payoff. @Nils mentioned menubar items (which I already create with Butler, and tbh probably have way too many of as it is). Anything else worth mentioning?
Come to think of it, maybe the question I really want to ask is not what HS can do that can’t be done in KM, but what it can do that can’t be done in AppleScript or AppleScriptObjectiveC.
If you think it’s a hassle, then it’s probably not for you
I never got to the point where I can just write an AppleScript, I always have to google because it is so quirky. Lua is also quite strange (coming from Python), but at least my first try is much closer to the final script.
I suggest you scroll through the Hammerspoon API and see if anything jumps out to you. Maybe even look at Spoons created by other users to get a feeling.
I‘d say that it is probably not so impressive, if you compare it to KM’s features. However, it you want to edit your automations in your favorite text editor, then definitely give it a try.
To give another (less metaphorical) take on @chri.sk’s answer, I’d like to quote from the docs
you can write Objective-C extensions to expose new areas of system functionality
so if that is your thing, then your Mac is the limit. Or you Objective-C skills…
I’ve been playing with hammerspoon recently. I love Keyboard Maestro, but I find I can get the AutoNation I need in hammerspoon much more quickly.
KM packs a lot into some of its action blocks, and I find it very uninintuitive sometimes the way a given block can do multiple fairly distinct things — figuring out how to get them to do what I want can be frustrating for me.
Anyway, if you like writing code more than moving visual blocks around, give hs a try. For now I’m using it alongside KM, but I find myself turning to it for new automations more and more.
Hi, what really throws me about Hammerspoon is that there seems to be really scant documentation or blog-posts or tutorials about how to incorporate AppleScript into the mix. I mean, I get it, it is supported, but how. There’s a link to an API doc but that has changed to this link, and I don’t see actual examples anywhere for this.
What I’m trying to do is boot up a deeplink to System Settings using macOS Ventura, directly to the Software Update tab in System Settings. I have the deeplink, but I can’t figure out 1) how to launch it with AppleScript 2) how to run AppleScript from within Hammerspoon.
I’m kinda getting ready to give up altogether on Hammerspoon, it just hasn’t been fun, ya know? And the lack of real-life examples (and what are these Spoons anyway?!) is really throwing me. I’ll stick with this for a while, because of the menubar possibilities, and hopefully I’ll get something going, but I’m starting to really worry.
I use Hammerspoon extensively. Mostly for putting keystrokes to URLs (including url schemes, not just websites). I’ve never used it for System Preferences, however, so I’m not sure I’ll be much help. (I’m also doing very little on the computer atm.)
I recall finding examples on the site, but for a lot of things, you may want to look at lua programming references. When I got stuck, it was often on that kind of thing rather than Hammerspoon per Dr.
Short answer: No, not really
Years ago I had invested in BetterTouchTool and decided to fill the shortcomings of BTT (of that time) with Hammerspoon (the latter being free). Nowadays BetterTouchTool and Keyboard Maestro are much more capable.
That being said, HS contains all of the possible interactions with the OS and exposes them equally as a true API, whereas BTT/KM did the effort to arrange and rank actions in a UI that make them easier to find and configure, while maybe not covering too niche requirements.
Today I can’t imagine a use case that would justify HS over BTT/KM. I re-read my current HS code and I think I could translate all of those in BTT, maybe with some AppleScript and Shortcuts here and there.
I do have to say that I enjoyed the challenge of understanding and debugging LUA code for my needs.
Update: Okay I answered too quickly, I still need Hammerspoon for a bunch of things related to the fact that I plug my MacBook in clamshell mode on a desk:
- Auto-set my webcam as input device when I’m at my desk
- Auto-set my iPhone Mic (continuity camera) as input device when the webcam wasn’t available
- Auto-open Spotify (minimized) when my Bluetooth headphones connect
- Auto-disconnect Wifi when Ethernet is detected (otherwise the Mac gets stupid sometimes and uses the worst of either)
- Display a notification when the wifi name changes or disconnects (not specific ones)
- Auto-mute when unlocking/waking system
can you automate the Mac waking with Hammerspoon? This method wasn’t very reliable for me. How to Schedule Boot / Turn On, Shutdown, Wake / Sleep on MacOS Ventura
While I cannot answer your question about Hammerspoon, if the real issue is automating waking up your Mac, then maybe Power Manager is worth a look.
I used it a couple years back to wake up a Mac, run some stuff, and then shut it down. I’ve not used it in a while however.
(And Hammersoon is one of those things on my backlog of things to try … someday …)
What is it exactly that you want to achieve that Power Manager cannot do? Hammerspoon being a “normal” app it cannot execute such system actions for you; and the command-line solution you found requires typing your password which is something you can’t automate unless by putting your Mac’s security at risk.
Power Manager is subscription based app, I’m trying to cut down on the number of subscriptions that I have. Also, the iMac that the Power Manager application was installed on is now out of service and I don’t feel like hunting down the license of the application to reinstall it into my new machine.
There is a non-subscription “Professional” version available as well.