Live data from Hacker News

Hammerspoon – Lua-based powerful tool automation of macOS

hammerspoon.org

71–80 of 84 posts

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

#71
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 very much for your work! I am slowly oscillating between Keyboard Maestro and Hammerspoon, as well as between Alfred and Launchbar, but currently I am again in the Hammerspoon/Launchbar side of the pool :) One side I've noticed Hammesrpoon is a bit difficult to work with is debugging it can be done with logging to the console, but is not very convenient. Are there plans to introduce something more advanced…

I've used ZeroBrane to debug HS in the past: https://github.com/Hammerspoon/hammerspoon/issues/1268

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

#72
post #38

If anyone cares, here's my config: https://github.com/kbd/setup/blob/master/HOME/.hammerspoon/i... It shows off a tiny bit of what you can do with Hammerspoon: - window and app management - keyboard shortcuts for common apps (eg. hyper+T for text editor, hyper+B for browser, hyper+S for shell) - if you can code a tiny bit of Lua there's no need for apps like Spectacle, Rectangle, Moom, etc. because it's easy to posit…

Thank you so much for your sample config. I recently got a Macbook for work, and coming back to non-tiling wm has been a challenge, especially with multiple monitors. With this config I am finally back to my comfortable meta+{h,l} tiling, dedicated shortcuts for applications and easy way to move application between monitors. And it took less than 10 minutes. Excellent way to start a Monday.

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

#73
I'm a big fan of hammerspoon, but not so much Lua. I also use emacs with Doom, where a lot of bindings are behind a 'leader key'. I found an awesome framework called 'spacehammer'[1] that fits very well into the way I like to work. It similarly hides binding behind a leader, and it's written in Fennel, a lisp that compiles to Lua. I feel like I get to expand the customizability of Emacs out to my whole system and I love it. Hammerspoon is pretty bare on its own so I suggest you check out spacehammer even if it's just a show case of the potential of hammerspoon.

[1] https://github.com/agzam/spacehammer

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

#74

I'm a big fan of hammerspoon, but not so much Lua. I also use emacs with Doom, where a lot of bindings are behind a 'leader key'. I found an awesome framework called 'spacehammer'[1] that fits very well into the way I like to work. It similarly hides binding behind a leader, and it's written in Fennel, a lisp that compiles to Lua. I feel like I get to expand the customizability of Emacs out to my whole system and I l…

Was using a few paid apps for various automation tasks on OS X:

- Hazel for automated tasks - Mosaic for layout shortcuts - Moom for layout grid drawing

Since discovering spacehammer, was able to use it to replace all those tools. Even had the opportunity to create one of my dream features: Can highlight any code sample in a browser or most other apps, press leader-t and select the tmux session to send the code, turning just about any page into a repl driven workflow.

A few years back I started contributing to spacehammer and refactored it to use a centralized config to make it easier for people to jump in and customize the menu and features.

Lua is ok to me but much prefer lisp languages like fennel, code feels more expressive and faster to produce using paredit lisp editing shortcuts in my editor.

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

#75
post #46

I fell briefly in love with Hammerspoon, but stopped using it. My MacOS automation is now my QMK keyboard calling Alfred workflows; I use Yabai for window management. I admire Lua, but ran into some sharp edges learning to program in it. Still, one can get up to speed quickly if one knows other scripting languages. Hammerspoon window management was deathly slow. Yabai is close to instantaneous.

Doesn’t Yabai require disabling SIP?

Certain advanced features do, but a majority of its features does not require disabling SIP.

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

#76
post #71

Earlier quoted context omitted.

Thank you very much for your work! I am slowly oscillating between Keyboard Maestro and Hammerspoon, as well as between Alfred and Launchbar, but currently I am again in the Hammerspoon/Launchbar side of the pool :) One side I've noticed Hammesrpoon is a bit difficult to work with is debugging it can be done with logging to the console, but is not very convenient. Are there plans to introduce something more advanced…

I've used ZeroBrane to debug HS in the past: https://github.com/Hammerspoon/hammerspoon/issues/1268

Ah, almost, but it seems that ZeroBrane Studio is not arm-ready :(

dlopen(/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/socket/core.dylib, 0x0006): tried: '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/socket/core.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/core.dylib' (no such file)

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

#77
post #38

If anyone cares, here's my config: https://github.com/kbd/setup/blob/master/HOME/.hammerspoon/i... It shows off a tiny bit of what you can do with Hammerspoon: - window and app management - keyboard shortcuts for common apps (eg. hyper+T for text editor, hyper+B for browser, hyper+S for shell) - if you can code a tiny bit of Lua there's no need for apps like Spectacle, Rectangle, Moom, etc. because it's easy to posit…

Thank you so much for your sample config. I recently got a Macbook for work, and coming back to non-tiling wm has been a challenge, especially with multiple monitors. With this config I am finally back to my comfortable meta+{h,l} tiling, dedicated shortcuts for applications and easy way to move application between monitors. And it took less than 10 minutes. Excellent way to start a Monday.

Awesome, you made my day better knowing that it helped someone. Thanks for your comment!

FWIW the rest of my (Mac-based) system config is all open source (both the files I linked are in the same repo) so feel free to steal anything else.

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

#78

I don’t use Mac but it seems that this is the app that keeps popping up whenever I find out that some kind of desktop/window manager automation is easier on Mac than on Linux. Nice.

I thought AHK on Windows was awesome but was disappointed when I moved permanently to Linux and found it was not ported. Autokey is doing an ok stand-in job. I suspect Hammerspoon is good. I've never been on a Mac, maybe some day when I sell the mare.

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

#79

Earlier quoted context omitted.

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] h…

yup this is very similar to what I ended up with:

    -- open Chrome Canary with a specific named Profile
    function canaryWithProfile(profile, url)
      local t = hs.task.new("/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
      nil,
      function() return false end,
      { "--profile-directory=" .. profile, url })
      t:start()
    end

    -- open Chrome with a specific named Profile
    function chromeWithProfile(profile, url)
      local t = hs.task.new("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
      nil,
      function() return false end,
      { "--profile-directory=" .. profile, url })
      t:start()
    end

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

#80
post #63

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…

> 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. Aka how everyone did it before Spotify took off. But actually, I'm told time and again that Spotify ha…

More to the point, Hammerspoon itself has functions to control Spotify: http://www.hammerspoon.org/docs/hs.spotify.html
Post reply on HN