Live data from Hacker News

Hammerspoon – Lua-based powerful tool automation of macOS

hammerspoon.org

51–60 of 84 posts

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

#51

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.

Not OP, but I found this after a little bit of searching:

https://gist.github.com/dshnkao/10865f32d69e40dc591e08e3af97...

Shouldn't be that hard to spawn a terminal with this running from hammerspoon.

Here's some Spoons that handle translation:

https://github.com/Hammerspoon/Spoons/blob/master/Source/Dee... https://github.com/Hammerspoon/Spoons/blob/master/Source/Pop...

I have quite a bit of experience with HS, let me know if you have any questions / need any help.

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

#52
My pretty extensive (but poorly organized) config:

https://github.com/nonissue/hammerspoon

Features include: - TOTP menubar app (that automatically types the code when clicked) - A menubar app for quickly changing screen resolution - A menubar sleep timer - Window management with convenient hot keys and undo functionality - Capslock rebinding to ESC when pressed alone, CTRL when pressed with other keys - A utility to allow you to both save a screenshot to disk AND have it copied to clipboard (AFAIK you can't do this natively in macOS).

There's other a bunch of other stuff, but those are the highlights. If you have any questions about it, please let me know! (email: andy@nonissue.org or open an issue on github).

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

#53
post #36
post #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 :) H…

Please forgive what may be a naive question: Speaking of old and terrible... Are you planning to keep the project in Objective-C long term? Any chance of migrating to Swift? Merry Christmas and thanks for a great project.

I don’t think that’s a naive question at all, it’s something I’ve been thinking about a lot recently.

We have something like 70k-75k lines of ObjC and plain C in Hammerspoon, written at various times over the last 7ish years, with varying architectural styles as we’ve figured out better ways of doing things.

I would love to have it all ported to Swift with a single, consistent architecture, but it’s a heck of a lot of work!

I’ve been experimenting with some ideas for how the Swift might look, but to really justify all that work I think we’d need to revamp how our user-facing API works, so we’d also be forcing all our users to rewrite their Lua configs.

In summary… ¯\_(ツ)_/¯

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

#54

Earlier quoted context omitted.

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!

I had a similar reaction, although annoyingly it seems that on my Debian system it doesn't expand text inside gnome-terminal. Inside Emacs, Firefox, and similar it does work but if it's not "everywhere" I suspect I'll get frustrated.

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

#55

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(…

Another fun thing you can do is install Hammerspoon as your URL handler, and make certain URLs open in different Chrome profiles--any work websites open in my work Chrome profile, websites related to a game I play opens in a Chrome profile specific to that, and anything else opens up in a personal Chrome profile. I've also setup cmd+shift+1/2/3 to brings the aforementioned profiles into the foreground, so e.g. cmd+sh…

For anyone else trying to determine how to switch between Chrome profiles on macOS, I found a superuser post [0] In short you can run:

    open -a "Google Chrome" --args --profile-directory=$NAME
where $NAME for your current Chrome profile can be found by looking at Profile Path in chrome://version. The last directory in Profile Path is $NAME. The default $NAME is "Default" and another profile could be "Profile 5".

[0] https://superuser.com/questions/377186/how-do-i-start-chrome...

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

#56
post #31
post #9

Is there something like this for python?

The language used for this is incidental. The important part is all the OS interfaces exposed. If you know Python, you'll feel comfortable in Lua quickly.

Im just looking for some way to slap something like this on top of some python scripts. Currently I’m only aware of calling applescript like this for python: https://stackoverflow.com/a/41318195

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

#57
post #53
post #36

Earlier quoted context omitted.

Please forgive what may be a naive question: Speaking of old and terrible... Are you planning to keep the project in Objective-C long term? Any chance of migrating to Swift? Merry Christmas and thanks for a great project.

I don’t think that’s a naive question at all, it’s something I’ve been thinking about a lot recently. We have something like 70k-75k lines of ObjC and plain C in Hammerspoon, written at various times over the last 7ish years, with varying architectural styles as we’ve figured out better ways of doing things. I would love to have it all ported to Swift with a single, consistent architecture, but it’s a heck of a lot o…

Decision tree so you can stop pondering:

Does the current situation hinder progress?

- Yes: A lot?

  - Yes: rewrite

  - No: don't rewrite
- No: Don't rewrite

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

#59
post #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 :) H…

Thank you so much for Hammerspoon! It regularly makes my life much, much easier.

Only thing I'd wish is for it to be ported to Windows and be 100% compatible with my existing scripts. ;)

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

#60
post #8

Earlier quoted context omitted.

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.

I use KeyboardMaestro to run my applescript connection as well. It's the missing glue to easily assign hotkeys to scripts or make them automatically trigger when something on my mac happens
Post reply on HN