Hammerspoon

2026-03-1318:3417269github.com

Staggeringly powerful macOS desktop automation with Lua - Hammerspoon/hammerspoon

You can’t perform that action at this time.


Read the original article

Comments

  • By iLemming 2026-03-1321:231 reply

    Shameless plug/proud self-promotion - https://github.com/agzam/spacehammer "Spacemacs|Doom inspired Hammerspoon modal toolkit"

    I can't even work on Mac without it. It let's you do stuff like "alt+spc a b" (apps -> browser) or "alt+spc m j/k" (media -> vol up/down), or edit just about any text of any app in your editor (Emacs atm) - with all the tools you have there - spellchecking, thesaurus, translation, LLMs, etc.

    You can plug it to your favorite WM (I'm currently using Yabai) and do tons of other interesting things. Because it's all written in Fennel, one can develop things in a tight feedback loop with a connected REPL - e.g., I can ask Claude to inspect things in the running Slack app or Firefox and make interesting automations - all without ever leaving my editor.

    • By jedbrooke 2026-03-1322:072 reply

      > "alt+cmd m j/k" (media -> vol up/down)

      if only keyboards came with built in buttons for adjusting the volume… oh wait. Unless of course you are suffering on a touch bar mac, then I completely understand.

      • By zimpenfish 2026-03-1323:41

        > if only keyboards came with built in buttons for adjusting the volume…

        99% of my working day, my fingers are on or near alt/cmd/m/j/k (a nice easy position in the centre of the keyboard.)

        They are not on or indeed anywhere even vaguely near fn+f10/f11/f12 (which are, in fact, diametrically opposite corners of the keyboard.)

      • By iLemming 2026-03-1322:41

        It's not about "having" or "not having" keys for specific actions, it's all about freedom and feeling of control. When you take and apply the idea of modality, you quickly realize that you are no longer constrained with the number of combinations you can have or the type of keyboard you're using. Everything can be controlled by (mostly) using home-row keys - h/j/k/l - without having to memorize weird combinations of modifiers and keys - "was it Ctrl+Alt+Cmd F, or just Ctrl+Cmd F?"

        alt+cmd (was a typo, I meant to say alt+space), which is configurable - I myself prefer using cmd+space. That opens the "main" modal, from where you can configure "conditional branching" - e.g. "m" - for "media", or "a" - for "apps", so with "alt+space m j/k" you can do volume up/down, while pressing h/l could be "previous/next song". Then, "alt+spc a b" activates the browser, and "alt+spc a t" - could be bind to activate "terminal", etc.

        It only looks like you have to press more keys to achieve anything, in practice - you quickly develop muscle memory. Then switching between the apps, moving windows around and resizing them, controlling playback, etc. - it all gains incredible productivity without affecting the focus point. You don't need to keep moving your hand for the mouse, you don't need to memorize and deal with myriad of modifier-driven key combinations - you control precisely what you need, without ever having to contort your fingers to hold modifiers, without ever thinking "what should I bind this action to, all memoizable keys are already taken, I suppose I'll just bind it to this impossible combo with a key that has no semantic meaning for the thing..." With Spacehammer you can create mnemonically-handy actions e.g., "o f" for "Open in Finder", while in another context that may work as "Open in Firefox".

  • By cmsj 2026-03-1323:221 reply

    Hammerspoon maintainer here - I'm enjoying reading all the comments, and hoping that everyone isn't going to be annoyed that I'm mostly working on a v2 atm, which switches from Lua to JavaScript :D

    • By zimpenfish 2026-03-1323:43

      > a v2 atm, which switches from Lua to JavaScript :D

      Presumably that'll be released in [checks calendar] 18 days?

  • By incanus77 2026-03-1319:342 reply

    Hammerspoon is the glue that holds my Mac together. For a starter list of things to do with this app, a partial list of the things that I'm using it for:

      - Dumping all open Safari tabs to an Obsidian doc
      - Adding 'hyper' (Ctrl-Opt-Cmd) keybinds to pop a new window for:
        - Safari
        - Finder
        - Terminal / Ghostty
        - VS Code
        - Notes
        - Editing Hammerspoon/AeroSpace/Sketchybar config
        - Reloading Hammerspoon config
        - Reloading Sketchybar
        - Quitting all Dock apps except Finder
        - Screen lock
        - System sleep
        - Opening front Finder folder in VS Code
        - Opening front Safari URL on Archive.today
        - Showing front Safari window tab count
        - Showing front app bundle ID
        - Posting notification about current Music track
        - Controlling my Logi Litra light (various color temps/brightnesses)
        - Starting/stopping a client work timer
      - Tying it to AeroSpace for:
        - Pushing a window to another monitor
        - Performing a two-up window layout
        - Swapping those two windows
        - Closing all other workspace windows
        - Gathering all windows to first workspace
      - Ensuring some background apps stay running if they crash
      - Prompting to unmount disk images if trashed
      - Binding into Skim to jump to specific sections of spec PDFs using terse Markdown URLs

    • By joemi 2026-03-1322:27

      > - Dumping all open Safari tabs to an Obsidian doc

      I'd love to do this too. Would you mind sharing how you do it? Or is it trivially easy and not worth explaining? (I haven't looked too deeply into HS yet.)

    • By piskov 2026-03-1320:531 reply

      Keyboard stuff is better handled with Karabiner elements

      • By dbalatero 2026-03-1322:25

        Karabiner can _create_ new keys like hyper, but you _bind_ them with Hammerspoon.

HackerNews