Live data from Hacker News

Hammerspoon

github.com

81–90 of 154 posts

Re: Hammerspoon

#81
I recently set up Hammerspoon to surveil my own computer usage actions (active tab/window, typing state, scrolling) to have a next-action predictor. It shows the predicted next action at the top of the screen but I was thinking of using it to improve voice command accuracy.

Re: Hammerspoon

#82
post #68

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

Thank you for your work on Hammerspoon! I’ve been using it for years.

Would you mind elaborating on your vision for v2? Was there a certain limitation in the previous architecture that you’re trying to avoid this time around? Was there something in particular that drew you to choosing JavaScript for this version?

Re: Hammerspoon

#83
post #68

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

Hammerspoon is basically my only reason to write Lua, a language which I really like. I am sure JavaScript is a more pragmatic choice but I will be slightly saddened by it regardless.

Agreed, I never considered it a selling point but I did enjoy having an excuse to explore the language in Hammerspoon (and Neovim too).

Re: Hammerspoon

#85
post #19

I fake a tiling window manager on Mac with Hammerspoon, resizing to fit in specific corners/sizes: -- resize based on ratios function ratioResize(xr, yr, wr, hr) return function () local win = hs.window.focusedWindow() win:moveToUnit({x=xr,y=yr,w=wr,h=hr}) end end -- 4 corners, different sizes hs.hotkey.bind({"cmd", "ctrl"}, "w", ratioResize(0, 0, 2/5, 2/3)) hs.hotkey.bind({"cmd", "ctrl"}, "e", ratioResize(2/5, 0, 3/…

I do this too, really happy with my setup - I use hyper+arrow keys to move windows around a monitor (split in thirds on 40”+ or halves on the built-in screen), or jump to another monitor, and hyper+enter to fullscreen. When you push against an edge in full screen it reduces the window size in stages, it all feels natural.

Re: Hammerspoon

#86
I use it to: - implement a keyboard based window manager - arrange/quit/launch some things based on whether my MBP is docked or not - resize and reposition certain windows that don't remember their own size and position - certain other hotkeys - probably stuff I forgot and rely on!

I'll be sad when it moves from Lua to JavaScript, but I guess that's better than moving to Tcl.

Re: Hammerspoon

#87

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…

I pretty much only use it for two (related) things these days: - check the list of open Teams windows; if there's a non-standard one, assume I'm in a meeting and webhook to HomeAssistant to select the "active"[2] preset on my meeting light[0]. - download my work ical[1] and, if there's a pending meeting ( [0] Just a short strip of WS2812B connected to an ESP32 running WLED. [1] Originally this was a simple HTTP to my…

This is a great integration!

Re: Hammerspoon

#88
post #38

Earlier quoted context omitted.

Make caps lock a hyperkey (shift+ctrl+option+cmd) and use that for non-overlapping shortcuts

make caps lock control on hold, double quote on tap. Make control hyperkey on hold, angle bracket on tap. My keyboard firmware is very odd. This is not easily done with soft remaps to the point that I don't bother trying.

If you're on macOS have you tried Karabiner Elements? It seems to do just fine with software mapping my macbook keyboard.

Re: Hammerspoon

#89
post #59

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…

> - 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.)

It's not trivial, but roughly: use AppleScript/osascript to get the URLs, but mostly pass them to a ~50 line Bash script which:

  - Brings in the date path components for the dumped-to folder
  - Makes a hash of the URL for an Obsidian doc (each tab gets their own doc)
  - Uses Chrome command line (--headless --disable-gpu --dump-dom) to save a snapshot of the page contents
  - Uses it again with --screenshot to make a thumbnail
  - Create an Obsidian doc from a template
  - If it's a single tab dump, pass -o to the script, which opens it in Obsidian for review
Lastly, I use the relatively-new Bases feature in Obsidian to make a nice "cards" view of the docs with their thumbnails.

I'm hoping to clean it up at some point and maybe release it, but it's one of those classic one-shot systems that just works for me for now.

Re: Hammerspoon

#90
post #68

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

Have you though of some more modern language agnostic solution like wasm plugins users could write in anything, with the help of typed languages if they like? Or is that not feasible for a scripting project like this?
Post reply on HN