This may seem like a fairly complex set of options, but it’s worth spending some time learning, as it allows for extremely powerful window layouts, particularly in reaction to system events (such as the number of screens changing when you plug in a monitor, or even just press a particular hotkey to restore sanity to your windows). Note that we’re using the hs.geometry.rect() helper function to construct the rect table and that the y value is negative, meaning that the top of the window should start 48 pixels above the bottom of the display. This is shown in our example above, which will place the iTunes Mini Player window at the very bottom left of the screen, even if the dock is there. The sixth item is similar to the fifth, except it does take the OS menubar and dock into account. The fifth item is a rect that will be given to hs.window:setFrame() and should specify the position/size values as pixel positions on the screen, but without the OS menubar and dock taken into account. Open the Hammerspoon API docs in your browser, to explore the extensions we provide, and the functions they offerĪll good programming tutorials start with a Hello World example of some kind, so we will use Hammerspoon’s ability to bind keyboard hotkeys to demonstrate saying Hello World with a simple notification.Click on the Hammerspoon menu bar icon and choose Open Config from the menu.Run Hammerspoon.app and follow the prompts to enable Accessibility access for the app.Download the latest release of Hammerspoon and drag it to your /Applications folder.If you have never programmed in Lua before, you may want to run through Learn Lua in Y minutes before you begin. It bridges various system level APIs into a Lua scripting engine, allowing you to have powerful effects on your system by writing Lua scripts. Hammerspoon is a desktop automation tool for macOS. Thus far, in practice, I use 2 slot chains, with the right/left arrows controlling horizontal proportions, and the up/down arrows controlling vertical proportions but also bridging across my 2 displays which are arranged vertically.ĭivvy, Moom, Spectacle, and a bunch of in-built Hammerspoon packages are seem pretty good but didn’t quite do what I was looking for.Getting Started with Hammerspoon What is Hammerspoon? The code figures out which slot your window is in (or closest to), finds the next or previous slot in the slot chain and then moves and resizes the window to fit the target slot.Īs I hit Command-Control-Option Right/Left, the window moves through the slots: Here is the actual slot and connection definitions - This goes in your a local leftRightArrowSlotChain =, "Right", function () k2win.moveFocusedWindowToNextSlot ( leftRightArrowSlotChain, 1 ) end ) My approach was then to define slot chains, and then bind two hotkeys (a “next slot” and “previous” slot hotkey to move the focused window through the slot chain. Each slot has a next and previous neighbor slot. A slot chain is a linked set of slots.Any window from any app can “fit” into a slot. A slot is a rectangular region on a particular physical display.Hammerspoon has a straightforward set of window control functions you can access through Lua. It additionally has a separate hotkey for moving windows between displays - I wanted a single set that could move across displays naturally.I didn’t want symmetry between the up/down keys and right/left keys, as I use vertical space and horizontal space very differently.There’s a huge variety of Mac window management tools out there already 1, and Spectacle was probably the closest off the shelf, but: Low cognitive load to shift a window across physical displays - ideally the same set of hotkeys can spatially move windows across displays. No pre-defined app layouts as I tend to mix and match quite often. Small number of keystrokes to a desired layout outcome. But now most of my day is now spent in front of two monitors. “Every productivity improvement I make attempts to expand until I write a window management script” - meĬOVID accelerated this In the Physical Days pre-March 2020, I used a laptop in the office - no external displays of any kind. Those programs which cannot so expand are replaced by ones which can.” - jwz “Every program attempts to expand until it can read mail. One of my favorite programming quotes is:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |