Skip to content

Instantly share code, notes, and snippets.

@fabiant7t
Last active September 21, 2016 20:49
Show Gist options
  • Save fabiant7t/9389f9638bff170c1fce252f38c94342 to your computer and use it in GitHub Desktop.
Save fabiant7t/9389f9638bff170c1fce252f38c94342 to your computer and use it in GitHub Desktop.
hammerspoon configuration #1
-- Modifier
local hyper = {"cmd"}
-- Instant is better than animated
hs.window.animationDuration = 0
-- Window shadows off
hs.window.setShadows(false)
-- Grid
local grid = hs.grid
grid.setGrid('6x4')
grid.setMargins({0, 0})
hs.hotkey.bind(hyper, "G", grid.toggleShow)
-- Fullscreen toggle
hs.hotkey.bind(hyper, "space", function()
local window = hs.window.focusedWindow()
window:toggleFullScreen()
end)
-- iTerm launch and/or focus
hs.hotkey.bind(hyper, "return", function()
local launched = hs.application.launchOrFocus("iTerm")
end)
-- Focus
hs.hotkey.bind(hyper, 'H', function()
local win = hs.window.focusedWindow()
win:focusWindowWest(win:otherWindowsSameScreen(), true, false)
hs.mouse.setAbsolutePosition(hs.geometry.rectMidPoint(hs.window.focusedWindow():frame()))
end)
hs.hotkey.bind(hyper, 'J', function()
local win = hs.window.focusedWindow()
win:focusWindowSouth(win:otherWindowsSameScreen(), true, false)
hs.mouse.setAbsolutePosition(hs.geometry.rectMidPoint(hs.window.focusedWindow():frame()))
end)
hs.hotkey.bind(hyper, 'K', function()
local win = hs.window.focusedWindow()
win:focusWindowNorth(win:otherWindowsSameScreen(), true, false)
hs.mouse.setAbsolutePosition(hs.geometry.rectMidPoint(hs.window.focusedWindow():frame()))
end)
hs.hotkey.bind(hyper, 'L', function()
local win = hs.window.focusedWindow()
win:focusWindowEast(win:otherWindowsSameScreen(), true, false)
hs.mouse.setAbsolutePosition(hs.geometry.rectMidPoint(hs.window.focusedWindow():frame()))
end)
-- Window hints
local hints = hs.hints
hints.fontSize = 12
hints.titleMaxSize = 60
hints.showTitleThresh = 0 -- disable
hs.hotkey.bind(hyper, "Y", hints.windowHints)
-- set up your instance(s)
expose = hs.expose.new(nil, {showThumbnails=false})
expose_app = hs.expose.new(nil, {onlyActiveApplication=true})
expose_space = hs.expose.new(nil, {includeOtherSpaces=false})
expose_browsers = hs.expose.new{'Safari', 'Google Chrome', 'Firefox'}
hs.hotkey.bind(hyper, 'U','Expose', function() expose:toggleShow() end)
hs.hotkey.bind(hyper, 'I','App Expose', function() expose_app:toggleShow() end)
hs.hotkey.bind(hyper, 'O','Space Expose', function() expose_space:toggleShow() end)
-- Redhift
local wfRedshift=hs.window.filter.new({
VLC={focused=true},
Photos={focused=true},
loginwindow={visible=true, allowRoles='*'}
},'wf-redshift')
hs.redshift.start(2800,'21:00', '7:00', '4h', true, wfRedshift)
hs.hotkey.bind(hyper, 'f1', 'Invert', hs.redshift.toggleInvert)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment