Skip to content

Instantly share code, notes, and snippets.

@arkag
Created March 1, 2016 18:25
Show Gist options
  • Select an option

  • Save arkag/f523714acda3643dae6c to your computer and use it in GitHub Desktop.

Select an option

Save arkag/f523714acda3643dae6c to your computer and use it in GitHub Desktop.
Trying to get quartering to work in Hammerspoon
local function originalarrows()
prefix:bind('', 'Left', function() leftwin(false) end)
prefix:bind('', 'Right', function() rightwin(false) end)
prefix:bind('', 'Up', function() topwin(false) end)
prefix:bind('', 'Down', function() botwin(false) end)
end
local function newarrows()
prefix:bind('', 'Left', function() leftwin(true) end)
prefix:bind('', 'Right', function() rightwin(true) end)
prefix:bind('', 'Up', function() topwin(true) end)
prefix:bind('', 'Down', function() botwin(true) end)
end
local function leftwin(i)
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
if i then
f.x = f.x
f.y = f.y
f.w = max.w / 2
f.h = f.y
win:setFrame(f)
originalarrows()
prefix:exit()
else
f.x = max.x
f.y = max.y
f.w = max.w / 2
f.h = max.h
newarrows()
win:setFrame(f)
end
end
local function rightwin(i)
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
if i then
f.x = f.x
f.y = f.y
f.w = max.w / 2
f.h = f.y
win:setFrame(f)
originalarrows()
prefix:exit()
else
f.x = max.x + (max.w / 2)
f.y = max.y
f.w = max.w / 2
f.h = max.h
newarrows()
win:setFrame(f)
end
end
local function topwin(i)
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
if i then
f.x = f.x
f.y = f.y
f.w = f.w
f.h = max.h / 2
win:setFrame(f)
originalarrows()
prefix:exit()
else
f.x = max.x
f.y = max.y
f.w = max.w
f.h = max.h / 2
newarrows()
win:setFrame(f)
end
end
local function botwin(i)
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
if i then
f.x = f.x
f.y = f.y
f.w = f.w
f.h = max.h / 2
win:setFrame(f)
originalarrows()
prefix:exit()
else
f.x = max.x
f.y = max.y + (max.h / 2)
f.w = max.w
f.h = max.h / 2
newarrows()
win:setFrame(f)
end
end
originalarrows()
@arkag
Copy link
Copy Markdown
Author

arkag commented Mar 1, 2016

line 2: attempt to call a nil value (global 'leftwin')
line 3: attempt to call a nil value (global 'rightwin')
line 4: attempt to call a nil value (global 'topwin')
line 5: attempt to call a nil value (global 'botwin')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment