docs » WindowHalfsAndThirds

Simple window movement and resizing, focusing on half- and third-of-screen sizes

Download: https://github.com/Hammerspoon/Spoons/raw/master/Spoons/WindowHalfsAndThirds.spoon.zip

API Overview

API Documentation

Variables

clear_cache_after_seconds
Signature WindowHalfsAndThirds.clear_cache_after_seconds
Type Variable
Description

We don't want our undo frame cache filling all available memory. Let's clear it after it hasn't been used for a while.

Source Source/WindowHalfsAndThirds.spoon/init.lua line 77
defaultHotkeys
Signature WindowHalfsAndThirds.defaultHotkeys
Type Variable
Description

Table containing a sample set of hotkeys that can be assigned to the different operations.

Notes
  • These are not bound by default - if you want to use them you have to call: spoon.WindowHalfsAndThirds:bindHotkeys(spoon.WindowHalfsAndThirds.defaultHotkeys) after loading the spoon.
  • Value:
 {
    left_half   = { {"ctrl",        "cmd"}, "Left" },
    right_half  = { {"ctrl",        "cmd"}, "Right" },
    top_half    = { {"ctrl",        "cmd"}, "Up" },
    bottom_half = { {"ctrl",        "cmd"}, "Down" },
    third_left  = { {"ctrl", "alt"       }, "Left" },
    third_right = { {"ctrl", "alt"       }, "Right" },
    third_up    = { {"ctrl", "alt"       }, "Up" },
    third_down  = { {"ctrl", "alt"       }, "Down" },
    top_left    = { {"ctrl",        "cmd"}, "1" },
    top_right   = { {"ctrl",        "cmd"}, "2" },
    bottom_left = { {"ctrl",        "cmd"}, "3" },
    bottom_right= { {"ctrl",        "cmd"}, "4" },
    max_toggle  = { {"ctrl", "alt", "cmd"}, "f" },
    max         = { {"ctrl", "alt", "cmd"}, "Up" },
    undo        = { {        "alt", "cmd"}, "z" },
    center      = { {        "alt", "cmd"}, "c" },
    larger      = { {        "alt", "cmd", "shift"}, "Right" },
    smaller     = { {        "alt", "cmd", "shift"}, "Left" },
 }
Source Source/WindowHalfsAndThirds.spoon/init.lua line 22
logger
Signature WindowHalfsAndThirds.logger
Type Variable
Description

Logger object used within the Spoon. Can be accessed to set the default log level for the messages coming from the Spoon.

Source Source/WindowHalfsAndThirds.spoon/init.lua line 17
use_frame_correctness
Signature WindowHalfsAndThirds.use_frame_correctness
Type Variable
Description

If true, set setFrameCorrectness for some resizing operations which fail when the window extends beyonds screen boundaries. This may cause some jerkiness in the resizing, so experiment and determine if you need it. Defaults to false

Source Source/WindowHalfsAndThirds.spoon/init.lua line 72

Methods

bindHotkeys
Signature WindowHalfsAndThirds:bindHotkeys(mapping)
Type Method
Description

Binds hotkeys for WindowHalfsAndThirds

Parameters
  • mapping - A table containing hotkey objifier/key details for the following items:
    • left_half, right_half, top_half, bottom_half - resize to the corresponding half of the screen
    • third_left, third_right - resize to one horizontal-third of the screen and move left/right
    • third_up, third_down - resize to one vertical-third of the screen and move up/down
    • max - maximize the window
    • max_toggle - toggle maximization
    • left_third, middle_third_h, right_third - resize and move the window to the corresponding horizontal third of the screen
    • top_third, middle_third_v, bottom_third - resize and move the window to the corresponding vertical third of the screen
    • top_left, top_right, bottom_left, bottom_right - resize and move the window to the corresponding quarter of the screen
    • undo - restore window to position before last move
    • center - move window to center of screen
    • larger - grow window larger than its current size
    • smaller - shrink window smaller than its current size
Returns
  • the WindowHalfsAndThirds object
Source Source/WindowHalfsAndThirds.spoon/init.lua line 416
center
Signature WindowHalfsAndThirds:center(win)
Type Method
Description

Center window on screen

Parameters
  • win - hs.window to use, defaults to hs.window.focusedWindow()
Returns
  • the WindowHalfsAndThirds object
Source Source/WindowHalfsAndThirds.spoon/init.lua line 350
larger
Signature WindowHalfsAndThirds:larger(win)
Type Method
Description

Make win larger than its current size

Parameters
  • win - hs.window to use, defaults to hs.window.focusedWindow()
Returns
  • the WindowHalfsAndThirds object
Source Source/WindowHalfsAndThirds.spoon/init.lua line 368
leftHalf
Signature WindowHalfsAndThirds:leftHalf(win)
Type Method
Description

Resize to the left half of the screen.

Parameters
  • win - hs.window to use, defaults to hs.window.focusedWindow()
Returns
  • the WindowHalfsAndThirds object
Notes
  • Variations of this method exist for other operations. See WindowHalfsAndThirds:bindHotkeys for details:
    • .leftHalf .rightHalf .topHalf .bottomHalf .thirdLeft .thirdRight .leftThird .middleThirdH .rightThird
    • .thirdUp .thirdDown .topThird .middleThirdV .bottomThird .topLeft .topRight .bottomLeft .bottomRight
    • .maximize
Source Source/WindowHalfsAndThirds.spoon/init.lua line 268
smaller
Signature WindowHalfsAndThirds:smaller(win)
Type Method
Description

Make win smaller than its current size

Parameters
  • win - hs.window to use, defaults to hs.window.focusedWindow()
Returns
  • the WindowHalfsAndThirds object
Source Source/WindowHalfsAndThirds.spoon/init.lua line 392
toggleMaximized
Signature WindowHalfsAndThirds:toggleMaximized(win)
Type Method
Description

Toggle win between its normal size, and being maximized

Parameters
  • win - hs.window to use, defaults to hs.window.focusedWindow()
Returns
  • the WindowHalfsAndThirds object
Source Source/WindowHalfsAndThirds.spoon/init.lua line 313
undo
Signature WindowHalfsAndThirds:undo(win)
Type Method
Description

Undo window size changes for win if there've been any in WindowHalfsAndThirds.clear_cache_after_seconds

Parameters
  • win - hs.window to use, defaults to hs.window.focusedWindow()
Returns
  • the WindowHalfsAndThirds object
Source Source/WindowHalfsAndThirds.spoon/init.lua line 336