Live data from Hacker News

Hammerspoon

github.com

61–70 of 154 posts

Re: Hammerspoon

#61
post #3

here is my entire config hs.hotkey.bind({"ctrl"}, "D", function() hs.grid.show() end) i've tried all of the other fancy window managers and for me nothing has ever beat the ease of use of just (1) ctrl-d to see the grid, (2) type the letter where you want the top left corner of your window to be, (3) type the letter where you want the bottom right corner to be window resized

[flagged]

Syncing configs is a pretty solved problem with dotfile repos. I even made a starter repo anyone can fork & use: https://github.com/dbalatero/dotfiles-starter

Re: Hammerspoon

#62
I despair at not being able to easily send a window to another space with a keyboard shortcut on macOS.

Yabai supports this perfectly (especially combined with instant, animation-free space switching) but it requires disabling system integrity protection--which is a non-starter on a work computer.

Aerospace solves it with their own spaces implementation.

I was able to put together a hammerspoon script that does the job decently enough for my purposes: https://gist.github.com/kcrwfrd/6f3dcaec0e08e0e77b2884588a34...

Re: Hammerspoon

#63
Some stuff I've made in Hammerspoon you can use:

- Vim mode everywhere in macOS: https://github.com/dbalatero/VimMode.spoon

- Modifier keys + click/drag to resize or move windows: https://github.com/dbalatero/SkyRocket.spoon

- Show an overlay helper of all your keybinds when you hold modifier keys down: https://github.com/dbalatero/HyperKey.spoon

And my huge pile of random scripts/configs: https://github.com/dbalatero/nixpkgs/tree/main/home/modules/...

Re: Hammerspoon

#65

Shameless plug/proud self-promotion - https://github.com/agzam/spacehammer "Spacemacs|Doom inspired Hammerspoon modal toolkit" I can't even work on Mac without it. It let's you do stuff like "alt+spc a b" (apps -> browser) or "alt+spc m j/k" (media -> vol up/down), or edit just about any text of any app in your editor (Emacs atm) - with all the tools you have there - spellchecking, thesaurus, translation, LLMs, etc.…

> "alt+cmd m j/k" (media -> vol up/down) if only keyboards came with built in buttons for adjusting the volume… oh wait. Unless of course you are suffering on a touch bar mac, then I completely understand.

It's not about "having" or "not having" keys for specific actions, it's all about freedom and feeling of control. When you take and apply the idea of modality, you quickly realize that you are no longer constrained with the number of combinations you can have or the type of keyboard you're using. Everything can be controlled by (mostly) using home-row keys - h/j/k/l - without having to memorize weird combinations of modifiers and keys - "was it Ctrl+Alt+Cmd F, or just Ctrl+Cmd F?"

alt+cmd (was a typo, I meant to say alt+space), which is configurable - I myself prefer using cmd+space. That opens the "main" modal, from where you can configure "conditional branching" - e.g. "m" - for "media", or "a" - for "apps", so with "alt+space m j/k" you can do volume up/down, while pressing h/l could be "previous/next song". Then, "alt+spc a b" activates the browser, and "alt+spc a t" - could be bind to activate "terminal", etc.

It only looks like you have to press more keys to achieve anything, in practice - you quickly develop muscle memory. Then switching between the apps, moving windows around and resizing them, controlling playback, etc. - it all gains incredible productivity without affecting the focus point. You don't need to keep moving your hand for the mouse, you don't need to memorize and deal with myriad of modifier-driven key combinations - you control precisely what you need, without ever having to contort your fingers to hold modifiers, without ever thinking "what should I bind this action to, all memoizable keys are already taken, I suppose I'll just bind it to this impossible combo with a key that has no semantic meaning for the thing..." With Spacehammer you can create mnemonically-handy actions e.g., "o f" for "Open in Finder", while in another context that may work as "Open in Firefox".

Re: Hammerspoon

#66
post #24
post #15

Earlier quoted context omitted.

What features are you trying to replicate from Aerospace?

Well, a tiling window and workspace manager. But as I am typing this, I’m realizing they hammerspoon can probably do some of the window placement, but maybe not handling workspaces and global state. I was hoping I could be lazy and ask, and a not-lazy person could give a ready made answer :)

It can definitely handle virtual workspaces and global state (if I'm understanding what you mean). I have an Aerospace-like implementation here: https://github.com/mybuddymichael/Helm.spoon

It has several features from Aerospace, but Hammerspoon's window management performance is not nearly as good as Aerospace's (not surprising!).

Overall, I've found it easier to just fork Aerospace and add various extra features to it, so that's what I'm doing now.

Re: Hammerspoon

#67
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/…

https://github.com/peterklijn/hammerspoon-shiftit

I use ShiftIt (a lovely project, but dead) reimplemented in Hammerspoon. It is very comprehensive.

Re: Hammerspoon

#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

Re: Hammerspoon

#69
post #3

here is my entire config hs.hotkey.bind({"ctrl"}, "D", function() hs.grid.show() end) i've tried all of the other fancy window managers and for me nothing has ever beat the ease of use of just (1) ctrl-d to see the grid, (2) type the letter where you want the top left corner of your window to be, (3) type the letter where you want the bottom right corner to be window resized

Wow... that's... incredible. I've used Hammerspoon forever and never knew that existed.

Just messing around I found you can extend the grid size with `hs.grid.setGrid('4x4')`, which you also may then want to shrink the text size with `hs.grid.ui.textSize = 30`, and finally if you use an alternative keyboard layout (eg: Colemak), you can set the grid to use it with `hs.grid.HINTS`. They really thought of everything with this feature.

Re: Hammerspoon

#70

Shameless plug/proud self-promotion - https://github.com/agzam/spacehammer "Spacemacs|Doom inspired Hammerspoon modal toolkit" I can't even work on Mac without it. It let's you do stuff like "alt+spc a b" (apps -> browser) or "alt+spc m j/k" (media -> vol up/down), or edit just about any text of any app in your editor (Emacs atm) - with all the tools you have there - spellchecking, thesaurus, translation, LLMs, etc.…

> "alt+cmd m j/k" (media -> vol up/down) if only keyboards came with built in buttons for adjusting the volume… oh wait. Unless of course you are suffering on a touch bar mac, then I completely understand.

> if only keyboards came with built in buttons for adjusting the volume…

99% of my working day, my fingers are on or near alt/cmd/m/j/k (a nice easy position in the centre of the keyboard.)

They are not on or indeed anywhere even vaguely near fn+f10/f11/f12 (which are, in fact, diametrically opposite corners of the keyboard.)

Post reply on HN