Skip to content

Instantly share code, notes, and snippets.

@philsnow
Created December 20, 2016 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philsnow/c19506dec17597ab9e4bf02f8d23e603 to your computer and use it in GitHub Desktop.
Save philsnow/c19506dec17597ab9e4bf02f8d23e603 to your computer and use it in GitHub Desktop.
-- Modal bindings, have to resort to this because on mac there
-- isn't a reserved modifier key for interacting with the OS.
modal_keymap = hs.hotkey.modal.new("cmd", "escape")
modal_keymap:bind('', 'escape', nil, function() modal_keymap:exit() end)
-- Maximize toggling
local window_table = {}
function toggleFocusedWindowFullscreen()
local focused_window = hs.window.focusedWindow()
local old_frame = window_table[focused_window:id()]
if old_frame == nil then
window_table[focused_window:id()] = focused_window:frame()
focused_window:maximize()
else
window_table[focused_window:id()] = nil
focused_window:setFrame(old_frame)
end
end
modal_keymap:bind('', 'return', nil, function()
modal_keymap:exit()
toggleFocusedWindowFullscreen()
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment