Guest User

Untitled

a guest
Oct 27th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.41 KB | None | 0 0
  1.  
  2. -- Call up the bar
  3. require("bar")
  4.  
  5. -- Hotkey mash
  6. local mash = {"cmd", "alt", "ctrl"}
  7. local mash_move = {"cmd", "ctrl"}
  8.  
  9. hs.alert("Reloaded Config")
  10.  
  11. -- instant window resizing
  12. hs.window.animationDuration = 0
  13.  
  14. -- Resize window to tile horizontally
  15. hs.hotkey.bind(mash, "Left", function()
  16. local win = hs.window.focusedWindow()
  17. if (win == nil) then return end
  18. local f = win:frame()
  19. local screen = win:screen()
  20. local max = screen:frame()
  21.  
  22. f.x = max.x + 30
  23. f.y = max.y + 40
  24. f.w = max.w / 2 - 40
  25. f.h = max.h - 80
  26. win:setFrame(f)
  27. end)
  28.  
  29. -- Resize window to tile horizontally
  30. hs.hotkey.bind(mash, "Right", function()
  31. local win = hs.window.focusedWindow()
  32. if (win == nil) then return end
  33. local f = win:frame()
  34. local screen = win:screen()
  35. local max = screen:frame()
  36.  
  37. f.x = max.x + max.w / 2 + 10
  38. f.y = max.y + 40
  39. f.w = max.w / 2 - 40
  40. f.h = max.h - 80
  41. win:setFrame(f)
  42. end)
  43.  
  44. -- Resize window to tile vertically
  45. hs.hotkey.bind(mash, "Up", function()
  46. local win = hs.window.focusedWindow()
  47. if (win == nil) then return end
  48. local f = win:frame()
  49. local screen = win:screen()
  50. local max = screen:frame()
  51.  
  52. f.x = max.x + 30
  53. f.y = max.y + 40
  54. f.w = max.w - 60
  55. f.h = max.h / 2 - 50
  56. win:setFrame(f)
  57. end)
  58.  
  59. -- Resize window to tile vertically
  60. hs.hotkey.bind(mash, "Down", function()
  61. local win = hs.window.focusedWindow()
  62. if (win == nil) then return end
  63. local f = win:frame()
  64. local screen = win:screen()
  65. local max = screen:frame()
  66.  
  67. f.x = max.x + 30
  68. f.y = max.y + (max.h / 2) + 10
  69. f.w = max.w - 60
  70. f.h = max.h / 2 - 50
  71. win:setFrame(f)
  72. end)
  73.  
  74. -- left, upper corner
  75. hs.hotkey.bind(mash, "pad7", function()
  76. local win = hs.window.focusedWindow()
  77. if (win == nil) then return end
  78. local f = win:frame()
  79. local screen = win:screen()
  80. local max = screen:frame()
  81.  
  82. f.x = max.x + 30
  83. f.y = max.y + 40
  84. f.w = max.w / 2 - 40
  85. f.h = max.h / 2 - 60
  86. win:setFrame(f)
  87. end)
  88.  
  89. -- Right, lower corner
  90. hs.hotkey.bind(mash, "pad3", function()
  91. local win = hs.window.focusedWindow()
  92. if (win == nil) then return end
  93. local f = win:frame()
  94. local screen = win:screen()
  95. local max = screen:frame()
  96.  
  97. f.x = max.x + (max.w / 2) + 10
  98. f.y = max.y + (max.h / 2) + 10
  99. f.w = max.w / 2 - 40
  100. f.h = max.h / 2 - 50
  101. win:setFrame(f)
  102. end)
  103.  
  104. -- Right upper corner
  105. hs.hotkey.bind(mash, "pad9", function()
  106. local win = hs.window.focusedWindow()
  107. if (win == nil) then return end
  108. local f = win:frame()
  109. local screen = win:screen()
  110. local max = screen:frame()
  111.  
  112. f.x = max.x + (max.w / 2) + 10
  113. f.y = max.y + 40
  114. f.w = max.w / 2 - 40
  115. f.h = max.h / 2 - 60
  116. win:setFrame(f)
  117. end)
  118.  
  119. -- Left lower corner
  120. hs.hotkey.bind(mash, "pad1", function()
  121. local win = hs.window.focusedWindow()
  122. if (win == nil) then return end
  123. local f = win:frame()
  124. local screen = win:screen()
  125. local max = screen:frame()
  126.  
  127. f.x = max.x + 30
  128. f.y = max.y + (max.h / 2) + 10
  129. f.w = max.w / 2 - 40
  130. f.h = max.h / 2 - 50
  131. win:setFrame(f)
  132. end)
  133.  
  134. -- Basic movement
  135. -- k decrease height
  136. -- h decrease width
  137. -- l increase width
  138. -- j increase height
  139.  
  140. hs.hotkey.bind(mash, "H", function()
  141. local win = hs.window.focusedWindow()
  142. if (win == nil) then return end
  143. local f = win:frame()
  144. f.w = f.w - 20
  145. win:setFrame(f)
  146. end)
  147.  
  148. hs.hotkey.bind(mash, "L", function()
  149. local win = hs.window.focusedWindow()
  150. if (win == nil) then return end
  151. local f = win:frame()
  152. f.w = f.w + 20
  153. win:setFrame(f)
  154. end)
  155.  
  156. hs.hotkey.bind(mash, "J", function()
  157. local win = hs.window.focusedWindow()
  158. if (win == nil) then return end
  159. local f = win:frame()
  160. f.h = f.h + 20
  161. win:setFrame(f)
  162. end)
  163.  
  164. hs.hotkey.bind(mash, "K", function()
  165. local win = hs.window.focusedWindow()
  166. if (win == nil) then return end
  167. local f = win:frame()
  168. f.h = f.h - 20
  169. win:setFrame(f)
  170. end)
  171.  
  172. -- Basic movement
  173. -- k move up
  174. -- h move left
  175. -- l move right
  176. -- j move down
  177.  
  178. hs.hotkey.bind(mash_move, "K", function()
  179. local win = hs.window.focusedWindow()
  180. if (win == nil) then return end
  181. local f = win:frame()
  182. f.y = f.y - 10
  183. win:setFrame(f)
  184. end)
  185.  
  186. hs.hotkey.bind(mash_move, "H", function()
  187. local win = hs.window.focusedWindow()
  188. if (win == nil) then return end
  189. local f = win:frame()
  190. f.x = f.x - 10
  191. win:setFrame(f)
  192. end)
  193.  
  194. hs.hotkey.bind(mash_move, "L", function()
  195. local win = hs.window.focusedWindow()
  196. if (win == nil) then return end
  197. local f = win:frame()
  198. f.x = f.x + 10
  199. win:setFrame(f)
  200. end)
  201.  
  202. hs.hotkey.bind(mash_move, "J", function()
  203. local win = hs.window.focusedWindow()
  204. if (win == nil) then return end
  205. local f = win:frame()
  206. f.y = f.y + 10
  207. win:setFrame(f)
  208. end)
  209.  
  210. -- Fullscreen
  211. hs.hotkey.bind(mash, "pad5", function()
  212. local win = hs.window.focusedWindow()
  213. if (win == nil) then return end
  214. local f = win:frame()
  215. local screen = win:screen()
  216. local max = screen:frame()
  217.  
  218. f.x = max.x + 30
  219. f.y = max.y + 40
  220. f.w = max.w - 60
  221. f.h = max.h - 80
  222. win:setFrame(f)
  223. end)
  224.  
  225. -- Launch Iterm2
  226. hs.hotkey.bind(mash, "T", function() os.execute("/Applications/iTerm.app/Contents/MacOS/iTerm2 --new-window &") end)
  227.  
  228. -- Multi monitor
  229. -- Move Next / Preivous Screen
  230. hs.hotkey.bind(mash_move, "N", hs.grid.pushWindowNextScreen)
  231. hs.hotkey.bind(mash_move, "P", hs.grid.pushWindowPrevScreen)
  232.  
  233. -- Reload config
  234. hs.hotkey.bind(mash, "R", function()
  235. hs.reload()
  236. end)
Add Comment
Please, Sign In to add comment