Live data from Hacker News

Hammerspoon – Lua-based powerful tool automation of macOS

hammerspoon.org

21–30 of 84 posts

Re: Hammerspoon – Lua-based powerful tool automation of macOS

#21
Since we've hit the front page of HN again, I've just released Hammerspoon 0.9.92, which contains a few fixes and some additions, but mostly refactored a significant amount of internal project structure to allow our build system to be replaced with something that isn't 5 years old and terrible.

As a result, it's possible that something broke which we didn't find in our internal testing. Please file GitHub issues :)

Happy Christmas y'all!

Re: Hammerspoon – Lua-based powerful tool automation of macOS

#22

Hammerspoon is great. I use it to manage windows (eg set vscode and a browser side-by-side when connected to an external display, full screen when not), add a hotkey to translate selected text with Deepl, to mute sound when the machine sleeps, and to launch a terminal with an fzf-based browser history searcher that beats Firefox’s hands down. It’s easy to use and has great docs. Lua is fun to write. HS is a really ni…

Do you mind sharing your code for the translation and fzf-history hotkeys? Those sound like useful applications.

Re: Hammerspoon – Lua-based powerful tool automation of macOS

#23
I've been using Phoenix (https://github.com/kasper/phoenix), which is hackable in JavaScript (here's my config: https://gist.github.com/rcarmo/5132874cdaf2755e42907508802e8...) and has a smaller scope (only window management), but haven't found it compelling enough to keep hacking at my config, so I'm back to Moom (https://manytricks.com/moom/), which would be perfect if it supported chaining sequences of sizing instructions (i.e., tile a window twice to the left to turn it from 1/2 to 1/3 width).

Re: Hammerspoon – Lua-based powerful tool automation of macOS

#24

I use this! - Mute my computer when I put it to sleep or when I change wifi networks - Hyper key - Mail.app menubar indicator - Spotify menubar current song - Shortcut to move mouse cursor to another monitor - Window switcher that only lists apps in the current workspace

Can you share your config?

Re: Hammerspoon – Lua-based powerful tool automation of macOS

#25

I love Hammerspoon. It's one of the first must-have-for-a-usable-laptop tools I set up when I get a new MacBook. Here are the top ways I'm using it right now: 1) Hide/show apps similar to how iTerm lets you bind a hotkey to hide/show a terminal. I've got ctrl+space set to Vimcal, alt+space set to midnight.app (a time tracker I'm building), and ctrl+alt+space set to Things. 2) Start/stop playing my work playlist of lo…

Would love to see the source for these! They sound like great uses

Re: Hammerspoon – Lua-based powerful tool automation of macOS

#26
post #17

I like Hammerspoon, but it's a bit of a pain to write the scripts with Lua - I don't use the language often and it usually takes a while to figure out syntax and necessary stdlib/Hammerspoon functions. Does someone have a hint on how to set up e.g. VSCode or IJ with Lua support and completion for Hammerspoon functions?

I’ve been learning Lua as part of Advent of Code. Honestly, the language has its quirks buts it’s so tiny that you could pick it up quite quickly. It’s become enjoyable to write —- I recommend!

Re: Hammerspoon – Lua-based powerful tool automation of macOS

#27
post #2

Really nice at first sight. I'm getting melancholic vibes of AutoHotKey reading the docs, which was arguably my first entry into professional programming. Knowing nothing about coding, I built a service desk automation back then — with (network file-) shared hotkeys and a real GUI, all in one single file... good times. Anyway, ever since switching to MacOS more than a decade ago, I've always been searching for an AHK…

I have been enjoying espanso[1], which at first glance is just a text-expanding keystoke saver, but can run shell scripts when it's doing its thing. So I can type :extip anywhere and it will curl ipinfo.io then pipe the json response through jq -r and leave my current external IP in whatever app I was typing in. 1: https://espanso.org/

Holy cow, espanso looks bonkers. Open source, completely cross-platform, fully extensible... it ticks all the boxes. Might just have to try it out tonight!

Re: Hammerspoon – Lua-based powerful tool automation of macOS

#29
I've hooked up Hammerspoon to a bunch of APIs for fast lookups: translation, autocorrect, company lookup, etc.

Translate (Requires Google Translate API key) https://github.com/pasiaj/Translate-for-Hammerspoon

Autocorrect: https://github.com/nathancahill/Anycomplete

Re: Hammerspoon – Lua-based powerful tool automation of macOS

#30
One of my more useful things, cmd+shift+m and cmd+shift+u to minimize all windows and un-minimize all windows of the active application. The un-minimize gets used more often (e.g. I may have a few Chrome windows minimized during my workday that I want to un-minimize en masse after work is done).

    local cmdShift = {'cmd', 'shift'}

    hs.hotkey.bind(cmdShift, 'm', function()
      local app = hs.application.frontmostApplication()

      for _, window in pairs(app:allWindows()) do
        window:minimize()
      end
    end)

    hs.hotkey.bind(cmdShift, 'u', function()
      local app = hs.application.frontmostApplication()

      for _, window in pairs(app:allWindows()) do
        window:unminimize()
      end
    end)
Post reply on HN