├── LICENSE ├── README.adoc ├── hammerspoon └── init.lua └── karabiner └── karabiner.json /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Matt Petty 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = hyper-hacks 2 | 3 | Here are my macOS Sierra hacks using some combination of Alfred 3, Karabiner-Elements, and Hammerspoon 4 | 5 | == Background: 6 | 7 | When macOS Sierra hit, everyone using a http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/[Hyper key hack] based off of Karabiner and Seil felt a deep loss. 8 | 9 | This hack with link:https://github.com/tekezo/Karabiner-Elements[Karabiner-Elements] and link:http://www.hammerspoon.org[Hammerspoon] brings back that old-time hyper key feel, complete with ESCAPE binding. 10 | 11 | == Installation: 12 | 13 | * Install Hammerspoon 14 | * Install Karabiner-Elements 15 | * Put `hammerspoon/init.lua` in `~/.hammerspoon/init.lua` 16 | * Put `karabiner/karabiner.json` in `~/.config/karabiner/karabiner.json` 17 | 18 | That's pretty much it. 19 | 20 | This is my first attempt and has a few examples in the `init.lua`. I aim to learn some more Lua and clean up the repetitious code. 21 | 22 | In the meantime, check out the link:https://github.com/lodestone/hyper-hacks/wiki[Wiki] for ideas on how to configure your `init.lua`. 23 | 24 | Reach out to me: 25 | 26 | Github:: @lodestone 27 | Twitter:: @lodestone 28 | Email:: lodestone@gmail.com 29 | -------------------------------------------------------------------------------- /hammerspoon/init.lua: -------------------------------------------------------------------------------- 1 | 2 | -- A global variable for the Hyper Mode 3 | k = hs.hotkey.modal.new({}, "F17") 4 | 5 | -- HYPER+L: Open news.google.com in the default browser 6 | lfun = function() 7 | news = "app = Application.currentApplication(); app.includeStandardAdditions = true; app.doShellScript('open http://news.google.com')" 8 | hs.osascript.javascript(news) 9 | k.triggered = true 10 | end 11 | k:bind('', 'l', nil, lfun) 12 | 13 | -- HYPER+M: Call a pre-defined trigger in Alfred 3 14 | mfun = function() 15 | cmd = "tell application \"Alfred 3\" to run trigger \"emoj\" in workflow \"com.sindresorhus.emoj\" with argument \"\"" 16 | hs.osascript.applescript(cmd) 17 | k.triggered = true 18 | end 19 | k:bind({}, 'm', nil, mfun) 20 | 21 | -- HYPER+E: Act like ⌃e and move to end of line. 22 | efun = function() 23 | hs.eventtap.keyStroke({'⌃'}, 'e') 24 | k.triggered = true 25 | end 26 | k:bind({}, 'e', nil, efun) 27 | 28 | -- HYPER+A: Act like ⌃a and move to beginning of line. 29 | afun = function() 30 | hs.eventtap.keyStroke({'⌃'}, 'a') 31 | k.triggered = true 32 | end 33 | k:bind({}, 'a', nil, afun) 34 | 35 | -- Enter Hyper Mode when F18 (Hyper/Capslock) is pressed 36 | pressedF18 = function() 37 | k.triggered = false 38 | k:enter() 39 | end 40 | 41 | -- Leave Hyper Mode when F18 (Hyper/Capslock) is pressed, 42 | -- send ESCAPE if no other keys are pressed. 43 | releasedF18 = function() 44 | k:exit() 45 | if not k.triggered then 46 | hs.eventtap.keyStroke({}, 'ESCAPE') 47 | end 48 | end 49 | 50 | -- Bind the Hyper key 51 | f18 = hs.hotkey.bind({}, 'F18', pressedF18, releasedF18) 52 | -------------------------------------------------------------------------------- /karabiner/karabiner.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": [ 3 | { 4 | "name": "Default profile", 5 | "selected": true, 6 | "simple_modifications": { 7 | "caps_lock": "f18" 8 | } 9 | } 10 | ] 11 | } 12 | --------------------------------------------------------------------------------