-
Notifications
You must be signed in to change notification settings - Fork 587
Krillere's init.lua (Window resizing and Safari tab hotkeys)
Krillere edited this page Apr 16, 2016
·
1 revision
Use: CMD + Alt + Ctrl + #Key# All keys move and resizes the active window to the values mentioned below.
Keys:
- I - Upper left corner, 1/4 of screen
- O - Upper right corner, 1/4 of screen
- K - Lower left corner, 1/4 of screen
- L - Lower right corner, 1/4 of screen
- Left - Left side of screen, 1/2 of screen
- Right - Right side of screen, 1/2 of screen
- Up - Top of screen, 1/2 of screen
- Down - Bottom of screen, 1/2 of screen
- F - Fullscreen
-- Safari tab keys
hs.hotkey.bind({"cmd"}, "1", function()
hs.osascript.applescript('tell front window of app "Safari" to set current tab to tab 1')
end)
hs.hotkey.bind({"cmd"}, "2", function()
hs.osascript.applescript('tell front window of app "Safari" to set current tab to tab 2')
end)
hs.hotkey.bind({"cmd"}, "3", function()
hs.osascript.applescript('tell front window of app "Safari" to set current tab to tab 3')
end)
hs.hotkey.bind({"cmd"}, "4", function()
hs.osascript.applescript('tell front window of app "Safari" to set current tab to tab 4')
end)
hs.hotkey.bind({"cmd"}, "5", function()
hs.osascript.applescript('tell front window of app "Safari" to set current tab to tab 5')
end)
hs.hotkey.bind({"cmd"}, "6", function()
hs.osascript.applescript('tell front window of app "Safari" to set current tab to tab 6')
end)
hs.hotkey.bind({"cmd"}, "7", function()
hs.osascript.applescript('tell front window of app "Safari" to set current tab to tab 7')
end)
hs.hotkey.bind({"cmd"}, "8", function()
hs.osascript.applescript('tell front window of app "Safari" to set current tab to tab 8')
end)
hs.hotkey.bind({"cmd"}, "9", function()
hs.osascript.applescript('tell front window of app "Safari" to set current tab to tab 9')
end)
-- left, upper corner
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "I", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x / 2
f.y = max.y / 2
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
-- Right, lower corner
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "L", function()
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
f.h = max.h / 2
win:setFrame(f)
end)
-- Right upper corner
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "O", function()
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 / 2
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
-- Left lower corner
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "K", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x / 2
f.y = max.y + (max.h / 2)
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
-- Fullscreen
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "F", function()
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)
end)
-- Right side
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Right", function()
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)
end)
-- Left side
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Left", function()
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)
end)
-- Bottom
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Down", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = 0
f.y = max.y + (max.h / 2)
f.w = max.w
f.h = max.h / 2
win:setFrame(f)
end)
-- Top
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Up", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = 0
f.y = 0
f.w = max.w
f.h = max.h / 2
win:setFrame(f)
end)