In case it's helpful, here's how I use hammerspoon:
* As a replacement for the classic caffeine app. [1]
* To provide shortcuts for window managements. [2]
* To shutdown bluetooth on sleep. Otherwise, devices I have setup to pair with both my mac and phone will tend to pair with the mac, even though it's asleep. [3]
I have a Kensington trackball and scrolling works fine with provided drivers or even without them. Just curious about hammerspoon was needed in your case.
Hammerspoon is one of my favorite tools. I especially like the low latency of the system hooks, other tools like Automator or Folder Actions have a couple second delay betweeen the trigger and the action. Hammerspoon is pretty much instant.
On top of that, Hammerspoon is very actively developed and the maintainers are super knowledgeable and responsive.
It is a truly great tool. The caveat is that using Hammerspoon is essentially programming. So it is "only" suitable for technical users like developers.
For the casual Mac user (e. g. product manager or the guy from sales) the visual Sikuli or UI.Vision RPA tools are more suitable for creating automation scripts.
I mean, macOS already has built in automation (with Automator) that you can write in AppleScript or JavaScript JXA. https://github.com/JXA-Cookbook/JXA-Cookbook is not very updated but its wiki contains quite a bit of useful recipes.
Hammerspoon is suited for tasks that keep working in the background. Plus it has access to stuff like arbitrary drawing on the screen, which AppleScript doesn't provide. The most used case is custom bindings for (almost) arbitrary hotkeys.
Automator/AppleScript are sufficient when you only need their standard hook points―services and such.
Btw, JXA is a big disappointment: it maps Objective-C/AppleScript's calls and especially structures very awkwardly instead of providing more JS-native experience. And afaik its official documentation is lacking.
One trick to finding JXA documentation is simply to look at the AppleScript documentation and translate the code to JavaScript syntax, or, depending on what you've doing, look at the Objective-C Cocoa documentation and translate the syntax.
For example, to obtain the current date and one day from now, in Objective-C you might write:
Exactly. It's been years since first released and nothing is really out there to tell you how to use it. I wish they would finish it up as it is much better that AppleScript.
Applescript seems to have been a mistake in that it is too irregular and programmers don't learn and use it. I researched the most highly thought of books on Applescript and even they were emphasizing how hard it was to know thoroughly.
Key insight: Apple event IPC is not OOP, it is RPC + simple first-class queries. It is far more closely related to SQL and relational databases than to DOM.
Unfortunately, programmers look at AppleScript syntax, which is superficially OO-like, and assume it is OOP. Which causes huge confusion and frustration when it behaves in completely non-OO ways.
The confusion is confounded by AppleScript’s fondness for “magical” behaviors—including overloading native language operators and automatically dispatching remote calls (aka “implicit gets”) without obvious rhyme or reason—plus enough syntactic sugar to rot anyone’s brain to mush.
Ironically, non-programmers don’t struggle nearly so much because they are operating on simple ignorance rather than outright misunderstanding, so they accept what it’s doing on face value, rather than trying to map everything they see onto completely the wrong mental model and getting utterly honked that prediction and observation refuse to match up.
In fact there are hard rules behind all of AS’s behavior, but they are utterly opaque and never adequately explained anywhere, so are largely indistinguishable from “What the F* is Going On?”. Hell, I rewrote most of the early chapters for the last edition of Apress’s AppleScript book, and even I bottled it as “too hard to explain to anyone else”.
..
Things might’ve turned out differently had AppleScript’s original designers not quit in disgust at Apple [mis]management shortly after AppleScript 1.1 went out, but when they walked out much of the expert insight and knowledge went with them, not to mention the ability to fix it once users’ feedback was pointing all its flaws out. But “coulda, woulda, shoulda” is the Mac Automation story throughout (my own failed contributions included).
Dr William Cook’s paper on the early history of AppleScript and its design and ambitions is well worth a read:
I used Hammerspoon as an AutoHotKey replacement for automating repetitive actions in games like Terraria.
I had macros for mining up, down, left, right, and in all diagonals (eventually expanded to also placing dirt below me so I don't fall into a chasm and die), and eventually integrated mining with placing rails for underground transport!
My reasoning was that I enjoyed the action parts but not the walking parts, so I made a train tunnel, but that was even more boring than walking, so I automated it. Eventually I was having more fun automating the game than playing it.
Oh, side note, getting infinite money and life in CheatEngine (also has Mac version now) taught me an important life lesson. Using my cheat-superpowers I defeated Wall of Flesh (who had been obstructing my progress for weeks), and suddenly felt a deep sense of dread. I hadn't really achieved anything, I had cheated! Suddenly I realized I had the exact same attitude towards the rest of my life, always trying to find an easy way out, a way to win without playing the game, and that this was a source of great dissatisfaction.
My favorite Hammerspoon use is binding applications to hotkeys, e.g. Ctrl-3 for editor, Ctrl-4 for terminal, Ctrl-5 for browser, etc. It is so much faster going directly to an app than cycling through the apps in the alt-tab switcher.
Additionally, I use it to bind caps lock to escape, unless it’s pressed with another key, in which case it’s curl. So it’s great to not need Karabiner anymore.
I moved at work from Ubuntu to Mac six months ago. I had AutoKey script for getting my most used password with keepassxc-cli and pasted it as text, which I had bound to Ctrl+F12. I tried to find an alternative to that on Mac and Hammerspoon was the most frequent search result. I couldn't find an easy enough example for me, though, so I went with Alfred + alfred-keepassxc workflow. It's completely different way to get passwords, how ever I prefer that now.
One funny thing while searching for information was that almost every Hammerspoon discussion had the mandatory "why not AppleScript?!" comment.
For me one important addition to Hammerspoon is Karabiner-Elements. I've binded my right Command and Option in a way so all my Hammerspoon shortcuts are just 2 keys. Like Right Command+T to open terminal.
If you want to go deeper into Karabiner-Elements, perhaps check out goku [0] — it allows you to write Karabiner configuration in a much nicer configuration language.
I recently picked up this tool and picked up someone's config that does some modal keybindings similar to spacemacs [1]. It actually inspired me to hack around with their config and then write a spacemacs layer for fennel-mode which someone had written a decent version of already [2]. I'm a bit of an emacs and fennel noob, but it seemed like a fun little problem to solve. I'm especially interested in getting autocomplete working better. I've been trying to base things off of other lisps' layers, but all ears for any tips on how to approach it. I'll edit in my github later as I have everything local at the moment.
Hi, I'm the author of Spacehammer. You may want to check development branch of the project. There are some major improvements. Sadly I've been swamped with work lately and having trouble finding more time to work on it.
One of the things I'm banging my head around is adding a REPL that can work with Hammerspoon's IPC.
Once I figure that out, I'm planning to experiment on a bunch of new things and improve existing features.
My idea is to extend fennel-mode with a fennel-hs-mode that will take preprocess code by removing newlines[1] and wrapping in something like
fennel.eval([=[ (code) ]=])
and then sending to the hs cli.
I haven't done much yet; this is the first time I've tried to write a real Emacs mode. It would be much nicer to have a real Fennel REPL integrated in Hammerspoon, but the above would be enough for things like eval-last-sexp and org-babel-eval.
[1] Sadly, the hs cli does not handle multi-line strings.
Oh very nice. I will check that out more later. Definitely love the concept and would be interested in hearing if you have any future plans. I thought it could be cool to define major and minor modes like emacs that you could also "autoload" based on application names or types or even use what monitors are plugged in/wifi/times of day to switch. I suppose you have major modes already with what application is focused.
A Spacehammer REPL would be huge for prototyping/developing new features in Fennel. My github is mitchellw. Would love to help out :)
Will publish it on my Github tonight (Japan time), mitchellw, then work on putting it in spacemacs develop branch when I can. It's crazy simple right now (just loads fennel-mode defines a few spacemacs-style keybindings for things available in that mode).
This is really nice. I repeatedly wish Apple hadn’t neutered AppleScript and the scripting bridges to the point they are unusable for doing window management and suchlike.
Love love love Hammerspoon; I use it every day. People point me to all their little utility apps to keep their screen on or perform window snapping and I just write a little script and bind it to my hyper key :)
I use hs.hotkey.modal to make Alt-Space pop up a modal window that tells me what I can do. Various keys open specific apps, e.g. Return opens Finder and Space opens iTerm. Other keys move and resize the currently window to specific areas. For example, I have a specific size and position for browser windows, another one for Finder windows, a third one for instant messaging windows, and a fourth one for terminal windows.
Very very rarely do I have to manually move windows around -- I find that almost all of my needs are covered with a set of specific window positions and sizes.
I also have a window selector that displays all windows and their names and allows me to use substrings to filter the list. But I find I never use it.
I used to use Hammerspoon to implement a "vi navigation" mode, toggled by tapping the Cmd key. In vi navigation mode, hjkl move the cursor, x deletes a character, and so on. But I discovered that Karabiner Elements can do something similar, and now I'm using that instead.
Currently, a number of things: for example, I use it to switch between apps, resize windows, change my screen resolution, and give me access to system information that I paste often. If you’re really curious I have a copy if my configuration here, though it’s a little bit out of date because I haven’t cleaned up some of my new additions yet: https://github.com/saagarjha/dotfiles/tree/master/.hammerspo...
I would probably have to stop using a mac without hammerspoon at this point.
For me it is indispensable as a hotkey launcher, keyboard, window mover/resizer, clipboard history manager, stay-awake, GIPHY API lookup, pomodoro timer, and a snippet manager.
My most used combo is ctrl (remapped capslock) - ' as a launcher, then C for Chrome, J for IntelliJ, V for MacVim, ... keeps me off cmd-tab which keeps me off seeing notification number in mail and slack.
Hammerspoon is my #1 tool for modding OSX to make it more usable.
Hammerspoon is awesome, can't even imagine how difficult it would be without it.
I've built Spacemacs inspired config so I can do everything and still keep my fingers in the home row
https://github.com/agzam/spacehammer
- Tossing windows around?
- Controlling music?
- Jumping between apps?
- Adding more convenient shortcuts for your favorite apps?
- Editing any text anywhere with your favorite editor?
Just for the web view or for the whole system? I think I’d rather look at and design dark mode content within the context of the whole screen in dark mode, but I could see that being handy for making quick little fixes.
I love the idea of Hammerspoon but I have yet to figure out a single concrete use-case for me that I actually care about. It feels like a lot of what I see people talking about is window management but I don't want window management (I actually like overlapping windows). Jumping between apps doesn't really matter either, I usually need my mouse with a lot of apps so it's not a big deal to click them in the dock if cmd-tab isn't good. And I already use an Alfred workflow for hotkeys to control iTunes.
I actually had Hammerspoon installed for multiple years on my home computer and the only thing I ever wrote with it was a hotkey to reload my Hammerspoon config.
While I’ve found hammerspoon works great for window management, I’ve recently explored trying to create semi advanced automation workflows with it and I agree that it’s not really fleshed out for this type of work (although it seems doable)
I've been using the totally outdated Slate [0] for years now and it still works through multiple MacOS upgrades. One day I'll port to Hammerspoon I keep telling myself. It probably won't happen until Slate stops working.
Hammerspoon is invaluable for providing window rearranging functions lost when Spectacle stopped working on my Mac. Unfortunately I haven't been able to understand the structure well enough to create my own scripts.
I mostly use Hammerspoon for moving windows to a fixed position with a keypress, e.g. left half, right third, move to other monitor. Not fully tiling, but close.
Possibly for the bug/feature that causes an iPhone connected by USB to connect and disconnect repeatedly on a ~2sec cycle, The bug leads to endless modals appearing on the iPhone, and sometimes iTunes opening with each reconnection.
Hammerspoon is free, but you have to write your automation scripts in Lua. If your comfortable with Lua this might be totally fine and give you a lot of flexibility.
Keyboard Maestro on the other side is commercial software with a nice UI editor were you can compose automation scripts by simply dragging and dropping actions.
Personally I use Keyboard Maestro and find it absolutely worth its money. Even without any programming experience you can create powerfull scripts within minutes. I use it as clipboard manager, snippet manager, text expansion and much more.
In case it's helpful, here's how I use hammerspoon:
* As a replacement for the classic caffeine app. [1]
* To provide shortcuts for window managements. [2]
* To shutdown bluetooth on sleep. Otherwise, devices I have setup to pair with both my mac and phone will tend to pair with the mac, even though it's asleep. [3]
1: https://gist.github.com/heptal/50998f66de5aba955c00
2: https://github.com/miromannino/miro-windows-manager
3: https://gist.github.com/ysimonson/fea48ee8a68ed2cbac12473e87...
I update my Slack status to "home|work" based on what wifi my laptop gets connected.
how do you do it, can you share your config
Wow, 1 and 3 are things I've really been wanting but didn't realize hammerspoon could do, thanks!
I'm already using hammerspoon for making scrolling work with my trackball mouse and it works great.
I have a Kensington trackball and scrolling works fine with provided drivers or even without them. Just curious about hammerspoon was needed in your case.
1 reply →
Hammerspoon is one of my favorite tools. I especially like the low latency of the system hooks, other tools like Automator or Folder Actions have a couple second delay betweeen the trigger and the action. Hammerspoon is pretty much instant.
On top of that, Hammerspoon is very actively developed and the maintainers are super knowledgeable and responsive.
I've shared a couple scripts on here before, like Anycomplete (Google autocomplete anywhere): https://news.ycombinator.com/item?id=13065670
It is a truly great tool. The caveat is that using Hammerspoon is essentially programming. So it is "only" suitable for technical users like developers.
For the casual Mac user (e. g. product manager or the guy from sales) the visual Sikuli or UI.Vision RPA tools are more suitable for creating automation scripts.
I mean, macOS already has built in automation (with Automator) that you can write in AppleScript or JavaScript JXA. https://github.com/JXA-Cookbook/JXA-Cookbook is not very updated but its wiki contains quite a bit of useful recipes.
Why would I prefer this over the built in option?
Hammerspoon is suited for tasks that keep working in the background. Plus it has access to stuff like arbitrary drawing on the screen, which AppleScript doesn't provide. The most used case is custom bindings for (almost) arbitrary hotkeys.
Automator/AppleScript are sufficient when you only need their standard hook points―services and such.
Btw, JXA is a big disappointment: it maps Objective-C/AppleScript's calls and especially structures very awkwardly instead of providing more JS-native experience. And afaik its official documentation is lacking.
AppleScript is awful to write and JXA is impossible to find documentation for.
One trick to finding JXA documentation is simply to look at the AppleScript documentation and translate the code to JavaScript syntax, or, depending on what you've doing, look at the Objective-C Cocoa documentation and translate the syntax.
For example, to obtain the current date and one day from now, in Objective-C you might write:
The equivalent in JavaScript is simply
10 replies →
And there's Fennel - an Lisp that compiles to Lua which makes writing Spoons (Hammerspoon plugins) pure joy.
https://fennel-lang.org/
2 replies →
"...impossible to find documentation for"
Exactly. It's been years since first released and nothing is really out there to tell you how to use it. I wish they would finish it up as it is much better that AppleScript.
3 replies →
Applescript seems to have been a mistake in that it is too irregular and programmers don't learn and use it. I researched the most highly thought of books on Applescript and even they were emphasizing how hard it was to know thoroughly.
Key insight: Apple event IPC is not OOP, it is RPC + simple first-class queries. It is far more closely related to SQL and relational databases than to DOM.
Unfortunately, programmers look at AppleScript syntax, which is superficially OO-like, and assume it is OOP. Which causes huge confusion and frustration when it behaves in completely non-OO ways.
The confusion is confounded by AppleScript’s fondness for “magical” behaviors—including overloading native language operators and automatically dispatching remote calls (aka “implicit gets”) without obvious rhyme or reason—plus enough syntactic sugar to rot anyone’s brain to mush.
Ironically, non-programmers don’t struggle nearly so much because they are operating on simple ignorance rather than outright misunderstanding, so they accept what it’s doing on face value, rather than trying to map everything they see onto completely the wrong mental model and getting utterly honked that prediction and observation refuse to match up.
In fact there are hard rules behind all of AS’s behavior, but they are utterly opaque and never adequately explained anywhere, so are largely indistinguishable from “What the F* is Going On?”. Hell, I rewrote most of the early chapters for the last edition of Apress’s AppleScript book, and even I bottled it as “too hard to explain to anyone else”.
..
Things might’ve turned out differently had AppleScript’s original designers not quit in disgust at Apple [mis]management shortly after AppleScript 1.1 went out, but when they walked out much of the expert insight and knowledge went with them, not to mention the ability to fix it once users’ feedback was pointing all its flaws out. But “coulda, woulda, shoulda” is the Mac Automation story throughout (my own failed contributions included).
Dr William Cook’s paper on the early history of AppleScript and its design and ambitions is well worth a read:
http://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf
2 replies →
I used Hammerspoon as an AutoHotKey replacement for automating repetitive actions in games like Terraria.
I had macros for mining up, down, left, right, and in all diagonals (eventually expanded to also placing dirt below me so I don't fall into a chasm and die), and eventually integrated mining with placing rails for underground transport!
My reasoning was that I enjoyed the action parts but not the walking parts, so I made a train tunnel, but that was even more boring than walking, so I automated it. Eventually I was having more fun automating the game than playing it.
Oh, side note, getting infinite money and life in CheatEngine (also has Mac version now) taught me an important life lesson. Using my cheat-superpowers I defeated Wall of Flesh (who had been obstructing my progress for weeks), and suddenly felt a deep sense of dread. I hadn't really achieved anything, I had cheated! Suddenly I realized I had the exact same attitude towards the rest of my life, always trying to find an easy way out, a way to win without playing the game, and that this was a source of great dissatisfaction.
Then you definitely should not learn about Minetest because it has open Lua API and this is how I play it
My favorite Hammerspoon use is binding applications to hotkeys, e.g. Ctrl-3 for editor, Ctrl-4 for terminal, Ctrl-5 for browser, etc. It is so much faster going directly to an app than cycling through the apps in the alt-tab switcher.
Additionally, I use it to bind caps lock to escape, unless it’s pressed with another key, in which case it’s curl. So it’s great to not need Karabiner anymore.
> My favorite Hammerspoon use is binding applications to hotkeys
In linux and windows you can just use the superkey+1, 2, etc. I'm surprised macos doesn't have the equivalent to this built in.
I moved at work from Ubuntu to Mac six months ago. I had AutoKey script for getting my most used password with keepassxc-cli and pasted it as text, which I had bound to Ctrl+F12. I tried to find an alternative to that on Mac and Hammerspoon was the most frequent search result. I couldn't find an easy enough example for me, though, so I went with Alfred + alfred-keepassxc workflow. It's completely different way to get passwords, how ever I prefer that now.
One funny thing while searching for information was that almost every Hammerspoon discussion had the mandatory "why not AppleScript?!" comment.
"why not AppleScript?!"
Rhetorical, shurely!?
Another big discussion here 3 years ago:
https://news.ycombinator.com/item?id=12097303
(Understand it's not a dupe; sharing for info purposes).
I thought I recognized Hammerspoon! thanks
For me one important addition to Hammerspoon is Karabiner-Elements. I've binded my right Command and Option in a way so all my Hammerspoon shortcuts are just 2 keys. Like Right Command+T to open terminal.
If you want to go deeper into Karabiner-Elements, perhaps check out goku [0] — it allows you to write Karabiner configuration in a much nicer configuration language.
[0] https://github.com/yqrashawn/GokuRakuJoudo
Please keep posting your little use cases!
I wrote a simple window manager that just lets me pick a set of windows across applications and bring them all to the front and cycle through them.
https://github.com/macrael/panes
It probably could be faster but it's so nice to be able to keep my terminal and my editor frontmost while I'm running tests with `entr`.
I recently picked up this tool and picked up someone's config that does some modal keybindings similar to spacemacs [1]. It actually inspired me to hack around with their config and then write a spacemacs layer for fennel-mode which someone had written a decent version of already [2]. I'm a bit of an emacs and fennel noob, but it seemed like a fun little problem to solve. I'm especially interested in getting autocomplete working better. I've been trying to base things off of other lisps' layers, but all ears for any tips on how to approach it. I'll edit in my github later as I have everything local at the moment.
[1] https://github.com/agzam/spacehammer [2] https://gitlab.com/technomancy/fennel-mode
Hi, I'm the author of Spacehammer. You may want to check development branch of the project. There are some major improvements. Sadly I've been swamped with work lately and having trouble finding more time to work on it. One of the things I'm banging my head around is adding a REPL that can work with Hammerspoon's IPC. Once I figure that out, I'm planning to experiment on a bunch of new things and improve existing features.
My idea is to extend fennel-mode with a fennel-hs-mode that will take preprocess code by removing newlines[1] and wrapping in something like
and then sending to the hs cli.
I haven't done much yet; this is the first time I've tried to write a real Emacs mode. It would be much nicer to have a real Fennel REPL integrated in Hammerspoon, but the above would be enough for things like eval-last-sexp and org-babel-eval.
[1] Sadly, the hs cli does not handle multi-line strings.
Oh very nice. I will check that out more later. Definitely love the concept and would be interested in hearing if you have any future plans. I thought it could be cool to define major and minor modes like emacs that you could also "autoload" based on application names or types or even use what monitors are plugged in/wifi/times of day to switch. I suppose you have major modes already with what application is focused.
A Spacehammer REPL would be huge for prototyping/developing new features in Fennel. My github is mitchellw. Would love to help out :)
Take a look at lsp-mode for auto-completion, syntax checking, etc. I think it already works well for Lua. Should be possible to do it for fennel too.
Yeah I think it should be possible to at least autocomplete parts that can be identified as the "lua bits" of Fennel. Just gotta dig in a bit more.
Is your fennel-mode spacemacs layer published on github or elsewhere? I couldn't find it in the spacemacs develop branch.
Will publish it on my Github tonight (Japan time), mitchellw, then work on putting it in spacemacs develop branch when I can. It's crazy simple right now (just loads fennel-mode defines a few spacemacs-style keybindings for things available in that mode).
1 reply →
This is really nice. I repeatedly wish Apple hadn’t neutered AppleScript and the scripting bridges to the point they are unusable for doing window management and suchlike.
Love love love Hammerspoon; I use it every day. People point me to all their little utility apps to keep their screen on or perform window snapping and I just write a little script and bind it to my hyper key :)
What do you use it for?
I use hs.hotkey.modal to make Alt-Space pop up a modal window that tells me what I can do. Various keys open specific apps, e.g. Return opens Finder and Space opens iTerm. Other keys move and resize the currently window to specific areas. For example, I have a specific size and position for browser windows, another one for Finder windows, a third one for instant messaging windows, and a fourth one for terminal windows.
Very very rarely do I have to manually move windows around -- I find that almost all of my needs are covered with a set of specific window positions and sizes.
I also have a window selector that displays all windows and their names and allows me to use substrings to filter the list. But I find I never use it.
I used to use Hammerspoon to implement a "vi navigation" mode, toggled by tapping the Cmd key. In vi navigation mode, hjkl move the cursor, x deletes a character, and so on. But I discovered that Karabiner Elements can do something similar, and now I'm using that instead.
I used to use Hammerspoon for a "vi
Currently, a number of things: for example, I use it to switch between apps, resize windows, change my screen resolution, and give me access to system information that I paste often. If you’re really curious I have a copy if my configuration here, though it’s a little bit out of date because I haven’t cleaned up some of my new additions yet: https://github.com/saagarjha/dotfiles/tree/master/.hammerspo...
I would probably have to stop using a mac without hammerspoon at this point.
For me it is indispensable as a hotkey launcher, keyboard, window mover/resizer, clipboard history manager, stay-awake, GIPHY API lookup, pomodoro timer, and a snippet manager.
My most used combo is ctrl (remapped capslock) - ' as a launcher, then C for Chrome, J for IntelliJ, V for MacVim, ... keeps me off cmd-tab which keeps me off seeing notification number in mail and slack.
Hammerspoon is my #1 tool for modding OSX to make it more usable.
Hammerspoon is awesome, can't even imagine how difficult it would be without it. I've built Spacemacs inspired config so I can do everything and still keep my fingers in the home row https://github.com/agzam/spacehammer
- Tossing windows around?
- Controlling music?
- Jumping between apps?
- Adding more convenient shortcuts for your favorite apps?
- Editing any text anywhere with your favorite editor?
Why not modality then?
Others have mentioned the window positioning features, but the other thing I use Hammerspoon for is a dark mode toggle in my menu bar.
Not something most people are switching all the time, but if you're writing CSS for a
media query, then being able to pop back and forth on demand is handy.
You can toggle between the two quickly from Safari’s Web Inspector.
Just for the web view or for the whole system? I think I’d rather look at and design dark mode content within the context of the whole screen in dark mode, but I could see that being handy for making quick little fixes.
1 reply →
I used it to get my IDE window into a pixel perfect size for recording screencasts. Pretty nifty tool.
I love the idea of Hammerspoon but I have yet to figure out a single concrete use-case for me that I actually care about. It feels like a lot of what I see people talking about is window management but I don't want window management (I actually like overlapping windows). Jumping between apps doesn't really matter either, I usually need my mouse with a lot of apps so it's not a big deal to click them in the dock if cmd-tab isn't good. And I already use an Alfred workflow for hotkeys to control iTunes.
I actually had Hammerspoon installed for multiple years on my home computer and the only thing I ever wrote with it was a hotkey to reload my Hammerspoon config.
While I’ve found hammerspoon works great for window management, I’ve recently explored trying to create semi advanced automation workflows with it and I agree that it’s not really fleshed out for this type of work (although it seems doable)
Seems like it's Lua with hooks into the OSX api.
Lots of useful examples https://www.hammerspoon.org/go/#table-of-contents
There's a great book by LeanPub on Hammerspoon.
I'm the author of that book! Glad you found it useful :)
I absolutely love Hammerspoon, it's my favorite Mac tool. My config is available here, in case anyone wants some ideas of what it can do: https://github.com/zzamboni/dot-hammerspoon/blob/master/init...
I've been using the totally outdated Slate [0] for years now and it still works through multiple MacOS upgrades. One day I'll port to Hammerspoon I keep telling myself. It probably won't happen until Slate stops working.
[0] https://github.com/jigish/slate
Hammerspoon is invaluable for providing window rearranging functions lost when Spectacle stopped working on my Mac. Unfortunately I haven't been able to understand the structure well enough to create my own scripts.
happy user. I LOVE Lua, and would happily use anything in lua.
I mostly use Hammerspoon for moving windows to a fixed position with a keypress, e.g. left half, right third, move to other monitor. Not fully tiling, but close.
I would love to have it to automate
Let's see if it works - Automator didn't work too well
Don't use Hammerspoon, but I've managed to create `sudo killall` keybindings with skhd by wrapping AppleScript.
Here's the relevant line from my skhd configuration. This does pop a password prompt, but it works. I imagine you could adapt this to fit Hammerspoon.
Just curious, why do you need to do this?
Possibly for the bug/feature that causes an iPhone connected by USB to connect and disconnect repeatedly on a ~2sec cycle, The bug leads to endless modals appearing on the iPhone, and sometimes iTunes opening with each reconnection.
2 replies →
Can it fix the language input switching (respect the default language and each app's language)?
Yes. I've made myself a config for that. Will share it in maybe a few hours.
However it works a bit slowly sometimes, but dunno if that's a problem with Hammerspoon or with my machine.
Does anyone know how Hammerspoon compares to keyboard maestro?
Hammerspoon is free, but you have to write your automation scripts in Lua. If your comfortable with Lua this might be totally fine and give you a lot of flexibility.
Keyboard Maestro on the other side is commercial software with a nice UI editor were you can compose automation scripts by simply dragging and dropping actions. Personally I use Keyboard Maestro and find it absolutely worth its money. Even without any programming experience you can create powerfull scripts within minutes. I use it as clipboard manager, snippet manager, text expansion and much more.
Also see WinTask for windows automation with VBA
hammerspoon would be great if they have a plugin store where non-power user can just browse and install plugin of their choice.
Anybody know if there is a python equivalent?
what do you guys think about RPA market ?
This is siiiiick