baby hammerspoon config
This commit is contained in:
parent
e520ee8421
commit
1fe2dfddae
1 changed files with 172 additions and 0 deletions
172
mac-files/.hammerspoon/init.lua
Normal file
172
mac-files/.hammerspoon/init.lua
Normal file
|
|
@ -0,0 +1,172 @@
|
||||||
|
--------------------------------------------
|
||||||
|
-- Set up
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
local hyper = {"shift", "cmd", "alt", "ctrl"}
|
||||||
|
|
||||||
|
hs.window.animationDuration = 0
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
-- hyper d for left one half window
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
hs.hotkey.bind(hyper, 'd', function()
|
||||||
|
if hs.window.focusedWindow() then
|
||||||
|
local win = hs.window.focusedWindow()
|
||||||
|
local f = win:frame()
|
||||||
|
local screen = win:screen()
|
||||||
|
local max = screen:frame()
|
||||||
|
|
||||||
|
f.x = max.x
|
||||||
|
f.y = max.y
|
||||||
|
f.w = max.w / 2
|
||||||
|
f.h = max.h
|
||||||
|
win:setFrame(f)
|
||||||
|
else
|
||||||
|
hs.alert.show("No active window")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
-- hyper g for right one half window
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
hs.hotkey.bind(hyper, 'g', function()
|
||||||
|
if hs.window.focusedWindow() then
|
||||||
|
local win = hs.window.focusedWindow()
|
||||||
|
local f = win:frame()
|
||||||
|
local screen = win:screen()
|
||||||
|
local max = screen:frame()
|
||||||
|
|
||||||
|
f.x = max.x + (max.w / 2)
|
||||||
|
f.y = max.y
|
||||||
|
f.w = max.w / 2
|
||||||
|
f.h = max.h
|
||||||
|
win:setFrame(f)
|
||||||
|
else
|
||||||
|
hs.alert.show("No active window")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
-- hyper f for fullscreen
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
hs.hotkey.bind(hyper, 'f', function()
|
||||||
|
if hs.window.focusedWindow() then
|
||||||
|
local win = hs.window.focusedWindow()
|
||||||
|
local f = win:frame()
|
||||||
|
local screen = win:screen()
|
||||||
|
local max = screen:frame()
|
||||||
|
|
||||||
|
f.x = max.x
|
||||||
|
f.y = max.y
|
||||||
|
f.w = max.w
|
||||||
|
f.h = max.h
|
||||||
|
win:setFrame(f)
|
||||||
|
else
|
||||||
|
hs.alert.show("No active window")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
-- hyper r for top left one quarter window
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
hs.hotkey.bind(hyper, 'r', function()
|
||||||
|
if hs.window.focusedWindow() then
|
||||||
|
local win = hs.window.focusedWindow()
|
||||||
|
local f = win:frame()
|
||||||
|
local screen = win:screen()
|
||||||
|
local max = screen:frame()
|
||||||
|
|
||||||
|
f.x = max.x
|
||||||
|
f.y = max.y
|
||||||
|
f.w = max.w / 2
|
||||||
|
f.h = max.h / 2
|
||||||
|
win:setFrame(f)
|
||||||
|
else
|
||||||
|
hs.alert.show("No active window")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
-- hyper t for top right one quarter window
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
hs.hotkey.bind(hyper, 't', function()
|
||||||
|
if hs.window.focusedWindow() then
|
||||||
|
local win = hs.window.focusedWindow()
|
||||||
|
local f = win:frame()
|
||||||
|
local screen = win:screen()
|
||||||
|
local max = screen:frame()
|
||||||
|
|
||||||
|
f.x = max.x + (max.w / 2)
|
||||||
|
f.y = max.y
|
||||||
|
f.w = max.w / 2
|
||||||
|
f.h = max.h / 2
|
||||||
|
win:setFrame(f)
|
||||||
|
else
|
||||||
|
hs.alert.show("No active window")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
-- hyper v for bottom left one quarter window
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
hs.hotkey.bind(hyper, 'v', function()
|
||||||
|
if hs.window.focusedWindow() then
|
||||||
|
local win = hs.window.focusedWindow()
|
||||||
|
local f = win:frame()
|
||||||
|
local screen = win:screen()
|
||||||
|
local max = screen:frame()
|
||||||
|
|
||||||
|
f.x = max.x + (max.w / 2)
|
||||||
|
f.y = max.y + (max.h / 2)
|
||||||
|
f.w = max.w / 2
|
||||||
|
f.h = max.h / 2
|
||||||
|
win:setFrame(f)
|
||||||
|
else
|
||||||
|
hs.alert.show("No active window")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
-- hyper c for bottom right one quarter window
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
hs.hotkey.bind(hyper, 'c', function()
|
||||||
|
if hs.window.focusedWindow() then
|
||||||
|
local win = hs.window.focusedWindow()
|
||||||
|
local f = win:frame()
|
||||||
|
local screen = win:screen()
|
||||||
|
local max = screen:frame()
|
||||||
|
|
||||||
|
f.x = max.x
|
||||||
|
f.y = max.y + (max.h / 2)
|
||||||
|
f.w = max.w / 2
|
||||||
|
f.h = max.h / 2
|
||||||
|
win:setFrame(f)
|
||||||
|
else
|
||||||
|
hs.alert.show("No active window")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
-- Reload config on write
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
function reload_config(files)
|
||||||
|
hs.reload()
|
||||||
|
end
|
||||||
|
hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reload_config):start()
|
||||||
|
hs.alert.show("Config loaded")
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
-- Hyper i to show window hints
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
hs.hotkey.bind(hyper, 'i', function()
|
||||||
|
hs.hints.windowHints()
|
||||||
|
end)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue