Live data from Hacker News

Hammerspoon – Lua-based powerful tool automation of macOS

hammerspoon.org

11–20 of 84 posts

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

#11
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 nice project.

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

#12
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…

do you mean simple text-based replacements and keyboard shortcuts? as opposed to full automation?

you can set those in the keyboard settings in system preferences. i have used the text replacement tab a lot in the past. i used it to auto-insert smileys and text snippets on various platforms. i haven't used shortcuts much though. you always end up with complicated shortcuts so you don't conflict with your apps.

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

#13
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 lofi hiphop. I got tired of the friction around opening Spotify, going into my work playlist, hitting play, waiting several moments for the playlist to load, etc, so I downloaded a bunch of mp3s from YouTube and put them in ~/Music/work/. Now my work music is a single keyboard shortcut (semicolon+m) and a few miliseconds away.

3) Set up screen recording. There are a few things that need to happen before I start a screen recording (opening CamHead.app, setting my screen resolution, and showing the dock at a certain height so I can later crop the video to 16:9) and I have it all bound to a single hotkey (semicolon+r). I've got another hotkey set up to unset it (semicolon+e).

4) You may have noticed I'm using keyboard shortcuts with semicolon as a modifier key. That's done with Hammerspoon too! I've got an extra layer of hotkeys available to me to set up whatever else I can think of in the future. The code I wrote to use semicolon like this sometimes breaks if I try to type too many actual semicolons in a row but I usually rely on JS Beautify to add those for me.

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

#14
post #8

Earlier quoted context omitted.

Have you tried AppleScript scripting? You can glue applications together and even use JavaScript if you’re not a fan of AppleScript

Did some, but the syntax wasn't my cup of tea. The _really_ great feature of AHK to me was having the triggers and the actions all in one place though, which is something I couldn't really replicate with AppleScript that only has the actions, with the triggers in Automator. So with that runtime you could easily just write whatever would happen if you press which key combo (or do cronjob-like things managed by the run…

Try Keyboard Maestro or BetterTouchTool. They remind me the most of AHK out of all the Apple options.

I also really like Hammerspoon. The desktop automation scene on macOS is strong.

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

#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?

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

#19
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

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

#20
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/

Post reply on HN