init.lua (5849B)
1 local hyper = {'cmd', 'alt', 'ctrl', 'shift'} 2 3 -- Load and create a new switcher 4 local HyperKey = hs.loadSpoon("HyperKey") 5 hyperKey = HyperKey:new(hyper) 6 7 -- Bind some applications to keys 8 hyperKey 9 :bind('l'):toApplication('/Applications/FSNotes.app') 10 11 -- Bind some functions to keys 12 local reloadHammerspoon = function() 13 -- hs.application.launchOrFocus("Hammerspoon") 14 hs.reload() 15 end 16 17 hyperKey 18 :bind('r'):toFunction("Reload Hammerspoon", reloadHammerspoon) 19 20 -------------------------------------------------------------------- 21 -- screen manipulation 22 -------------------------------------------------------------------- 23 24 -- -- option + ctrl + h to make active window half to the left 25 -- hs.hotkey.bind({"alt", "ctrl"}, "H", function() 26 -- local win = hs.window.focusedWindow() 27 -- local f = win:frame() 28 -- local screen = win:screen() 29 -- local max = screen:frame() 30 31 -- f.x = max.x 32 -- f.y = max.y 33 -- f.w = max.w / 2 34 -- f.h = max.h 35 -- win:setFrame(f) 36 -- end) 37 38 -- -- option + ctrl + l to make active window half to the right 39 -- hs.hotkey.bind({"alt", "ctrl"}, "L", function() 40 -- local win = hs.window.focusedWindow() 41 -- local f = win:frame() 42 -- local screen = win:screen() 43 -- local max = screen:frame() 44 45 -- f.x = max.x + (max.w / 2) 46 -- f.y = max.y 47 -- f.w = max.w / 2 48 -- f.h = max.h 49 -- win:setFrame(f) 50 -- end) 51 52 -- -- option + ctrl + j to make active window two-third to the left 53 -- hs.hotkey.bind({"alt", "ctrl"}, "J", function() 54 -- local win = hs.window.focusedWindow() 55 -- local f = win:frame() 56 -- local screen = win:screen() 57 -- local max = screen:frame() 58 59 -- f.x = max.x 60 -- f.y = max.y 61 -- f.w = max.w * (2/3) 62 -- f.h = max.h 63 -- win:setFrame(f) 64 -- end) 65 66 -- -- option + ctrl + k to make active window two-third to the right 67 -- hs.hotkey.bind({"alt", "ctrl"}, "K", function() 68 -- local win = hs.window.focusedWindow() 69 -- local f = win:frame() 70 -- local screen = win:screen() 71 -- local max = screen:frame() 72 73 -- f.x = max.x + (max.w * (1/3)) 74 -- f.y = max.y 75 -- f.w = max.w * (2/3) 76 -- f.h = max.h 77 -- win:setFrame(f) 78 -- end) 79 80 -- -- option + ctrl + i to make active window one-third to the right 81 -- hs.hotkey.bind({"alt", "ctrl"}, "I", function() 82 -- local win = hs.window.focusedWindow() 83 -- local f = win:frame() 84 -- local screen = win:screen() 85 -- local max = screen:frame() 86 87 -- f.x = max.x + (max.w * (2/3)) 88 -- f.y = max.y 89 -- f.w = max.w * (1/3) 90 -- f.h = max.h 91 -- win:setFrame(f) 92 -- end) 93 94 -- -- option + ctrl + u to make active window one-third to the left 95 -- hs.hotkey.bind({"alt", "ctrl"}, "U", function() 96 -- local win = hs.window.focusedWindow() 97 -- local f = win:frame() 98 -- local screen = win:screen() 99 -- local max = screen:frame() 100 101 -- f.x = max.x 102 -- f.y = max.y 103 -- f.w = max.w * (1/3) 104 -- f.h = max.h 105 -- win:setFrame(f) 106 -- end) 107 108 -- -- option + ctrl + s to make active window three-fourth to the left 109 -- hs.hotkey.bind({"alt", "ctrl"}, "S", function() 110 -- local win = hs.window.focusedWindow() 111 -- local f = win:frame() 112 -- local screen = win:screen() 113 -- local max = screen:frame() 114 115 -- f.x = max.x 116 -- f.y = max.y 117 -- f.w = max.w * (3/4) 118 -- f.h = max.h 119 -- win:setFrame(f) 120 -- end) 121 122 -- -- option + ctrl + d to make active window aligned right 123 -- hs.hotkey.bind({"alt", "ctrl"}, "D", function() 124 -- local win = hs.window.focusedWindow() 125 -- local f = win:frame() 126 -- local screen = win:screen() 127 -- local max = screen:frame() 128 129 -- f.x = max.x + max.w - f.w 130 -- f.y = max.y 131 -- win:setFrame(f) 132 -- end) 133 134 -- -- option + ctrl + c to make active window centered 135 -- hs.hotkey.bind({"alt", "ctrl"}, "C", function() 136 -- local win = hs.window.focusedWindow() 137 -- local f = win:frame() 138 -- local screen = win:screen() 139 -- local max = screen:frame() 140 141 -- -- f.x = max.x + (max.w * (1/6)) 142 -- -- f.y = max.y + (max.h * (1/6)) 143 -- -- f.w = max.w * (2/3) 144 -- -- f.h = max.h * (2/3) 145 -- -- f.x = max.x + (max.w * (1/8)) 146 -- -- f.y = max.y + (max.h * (1/8)) 147 -- -- f.w = max.w * (3/4) 148 -- -- f.h = max.h * (3/4) 149 -- f.x = max.x + (max.w * (3/16)) 150 -- f.y = max.y + (max.h * (2/16)) 151 -- f.w = max.w * (5/8) 152 -- f.h = max.h * (6/8) 153 -- win:setFrame(f) 154 -- end) 155 156 -- -- option + ctrl + c to make active window centered smaller 157 -- hs.hotkey.bind({"alt", "ctrl", "shift"}, "C", function() 158 -- local win = hs.window.focusedWindow() 159 -- local f = win:frame() 160 -- local screen = win:screen() 161 -- local max = screen:frame() 162 163 -- f.x = max.x + (max.w * (5/16)) 164 -- f.y = max.y + (max.h * (2/16)) 165 -- f.w = max.w * (3/8) 166 -- f.h = max.h * (6/8) 167 -- win:setFrame(f) 168 -- end) 169 170 -- -- option + ctrl + enter to make active window maximized 171 -- hs.hotkey.bind({"alt", "ctrl"}, "Return", function() 172 -- local win = hs.window.focusedWindow() 173 -- local f = win:frame() 174 -- local screen = win:screen() 175 -- local max = screen:frame() 176 177 -- f.x = max.x 178 -- f.y = max.y 179 -- f.w = max.w 180 -- f.h = max.h 181 -- win:setFrame(f) 182 -- end) 183 184 -- -- option + ctrl + N to make active window centered tall 185 -- hs.hotkey.bind({"alt", "ctrl"}, "N", function() 186 -- local win = hs.window.focusedWindow() 187 -- local f = win:frame() 188 -- local screen = win:screen() 189 -- local max = screen:frame() 190 191 -- f.x = max.x + (max.w * (4/16)) 192 -- f.w = max.w * (4/8) 193 -- f.y = max.y 194 -- f.h = max.h 195 -- win:setFrame(f) 196 -- end) 197 198 -- -- layoutWatcher = hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, function(e) 199 -- -- local flags = e:getFlags() 200 -- -- if flags.cmd and not (flags.alt or flags.shift or flags.ctrl or flags.fn) then 201 -- -- local keyCode = e:getKeyCode() 202 -- -- if keyCode == 0x37 then 203 -- -- hs.alert.show("left cmd key") 204 -- -- elseif keyCode == 0x36 then 205 -- -- hs.alert.show("right cmd key") 206 -- -- end 207 -- -- end 208 -- -- end):start() 209 210 hs.alert.show("Config loaded")