Last active
June 2, 2018 12:50
-
-
Save AndreFCruz/68efebeb22189c804460ebab1c0000fb to your computer and use it in GitHub Desktop.
My Hammerspoon configuration. Requires 'caffeine.lua' as seen below.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local obj = {} | |
| obj.__index = obj | |
| obj.menuBarItem = nil | |
| function obj:start() | |
| self.menuBarItem = hs.menubar.new() | |
| self.menuBarItem:setClickCallback(self.clicked) | |
| self.setDisplay(hs.caffeinate.get("displayIdle")) | |
| return self | |
| end | |
| function obj.setDisplay(state) | |
| if state then | |
| obj.menuBarItem:setTitle("AWAKE") | |
| -- result = obj.menuBarItem:setIcon("caffeine-on.pdf") | |
| else | |
| obj.menuBarItem:setTitle("SLEEPY") | |
| -- result = obj.menuBarItem:setIcon("caffeine-off.pdf") | |
| end | |
| end | |
| function obj.clicked() | |
| obj.setDisplay(hs.caffeinate.toggle("displayIdle")) | |
| end | |
| return obj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Hotkey Definition - CAPS is mapped to CTRL using karabiner -- | |
| hyper = {"ctrl"} | |
| hyper_cmd = {"ctrl", "cmd"} | |
| hyper_shft = {"ctrl", "shift"} | |
| -- Disable Animations | |
| hs.window.animationDuration = 0 | |
| -- Caffeine -- | |
| caffeine = require("caffeine"):start() | |
| -- init grid -- | |
| hs.grid.MARGINX = 0 | |
| hs.grid.MARGINY = 0 | |
| hs.grid.setGrid('2x2') | |
| -- Launch Applications -- | |
| hs.hotkey.bind(hyper, 'T', "Terminal", function () hs.application.launchOrFocus("Terminal") end) | |
| hs.hotkey.bind(hyper, 'R', "Sublime Text", function () hs.application.launchOrFocus("Sublime Text") end) | |
| hs.hotkey.bind(hyper, 'S', "Safari", function () hs.application.launchOrFocus("Safari") end) | |
| hs.hotkey.bind(hyper_cmd, 'S', "Spotify", function () hs.application.launchOrFocus("Spotify") end) | |
| hs.hotkey.bind(hyper, 'F', "Finder", function () hs.application.launchOrFocus("Finder") end) | |
| hs.hotkey.bind(hyper_cmd, 'X', "Xcode", function () hs.application.launchOrFocus("Xcode") end) | |
| hs.hotkey.bind(hyper_cmd, 'C', "Google Chrome", function () hs.application.launchOrFocus("Google Chrome") end) | |
| hs.hotkey.bind(hyper_cmd, 'V', "Visual Studio Code", function () hs.application.launchOrFocus("Visual Studio Code") end) | |
| hs.hotkey.bind(hyper_cmd, 'M', "Caprine", function () hs.application.launchOrFocus("Caprine") end) | |
| hs.hotkey.bind(hyper_cmd, 'D', "Dash", function () hs.application.launchOrFocus("Dash") end) | |
| -- Organize Windows -- | |
| hs.hotkey.bind(hyper, 'W', hs.grid.maximizeWindow) | |
| --hs.hotkey.bind(hyper_cmd, 'D', hs.grid.pushWindowRight) | |
| --hs.hotkey.bind(hyper_cmd, 'A', hs.grid.pushWindowLeft) | |
| function toUpper () | |
| function fn (cell) | |
| cell.y = 0 | |
| cell.x = 0 | |
| cell.w = 2 | |
| cell.h = 1 | |
| return hs.grid | |
| end | |
| hs.grid.adjustWindow(fn) | |
| end | |
| hs.hotkey.bind(hyper_shft, 'W', toUpper) | |
| function toLower () | |
| function fn (cell) | |
| cell.y = 1 | |
| cell.x = 0 | |
| cell.w = 2 | |
| cell.h = 1 | |
| return hs.grid | |
| end | |
| hs.grid.adjustWindow(fn) | |
| end | |
| hs.hotkey.bind(hyper_shft, 'S', toLower) | |
| function toUpperLeft () | |
| function fn (cell) | |
| cell.y = 0 | |
| cell.x = 0 | |
| cell.w = 1 | |
| return hs.grid | |
| end | |
| hs.grid.adjustWindow(fn) | |
| end | |
| hs.hotkey.bind(hyper, 'Q', toUpperLeft) | |
| function toUpperRight () | |
| function fn (cell) | |
| cell.y = 0 | |
| cell.x = 1 | |
| cell.w = 1 | |
| return hs.grid | |
| end | |
| hs.grid.adjustWindow(fn) | |
| end | |
| hs.hotkey.bind(hyper, 'E', toUpperRight) | |
| function toLowerRight () | |
| function fn (cell) | |
| cell.h = 1 | |
| cell.w = 1 | |
| cell.y = 1 | |
| cell.x = 1 | |
| end | |
| hs.grid.adjustWindow(fn, window) | |
| end | |
| hs.hotkey.bind(hyper, 'D', toLowerRight) | |
| function toLowerLeft () | |
| function fn (cell) | |
| cell.h = 1 | |
| cell.w = 1 | |
| cell.y = 1 | |
| cell.x = 0 | |
| end | |
| hs.grid.adjustWindow(fn, window) | |
| end | |
| hs.hotkey.bind(hyper, 'A', toLowerLeft) | |
| -- Window Hints | |
| hs.hotkey.bind(hyper, '.', hs.hints.windowHints) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment