Skip to content
cycle4passion edited this page Oct 7, 2016 · 9 revisions

Hyper Hacks

init.lua

Trigger existing hyper key shortcuts:

-- Trigger existing hyper key shortcuts k:bind({}, 'm', nil, function() hs.eventtap.keyStroke({"cmd","alt","shift","ctrl"}, 'm') end)

Call to a shell.

Make sure to include the full path to the script/binary.

k:bind({}, 's', nil, function() hs.task.new('/usr/bin/say', nil, {'Hello, this is a test'}):start(); end)

Launch or focus an App:

-- Launch or Focus an App launch = function(appname) hs.application.launchOrFocus(appname) k.triggered = true end k:bind({}, 'f', nil, function() launch('Finder') end)

Trigger another keystroke, HYPER+L sends ⌃L

-- Trigger another keystroke k:bind({}, 'l', nil, function() hs.eventtap.keyStroke({''}, 'l'); k.triggered = true; end)

Make a list of apps focusable with HYPER and a key

launch = function(appname) hs.application.launchOrFocus(appname) k.triggered = true end -- Single keybinding for app launch singleapps = { {'q', 'MailMate'}, {'w', 'OmniFocus'}, {'e', 'Sublime Text'}, {'r', 'Google Chrome'} } for i, app in ipairs(singleapps) do k:bind({}, app[1], function() launch(app[2]); k:exit(); end) end

Make HYPER+A,[key] focus an app

-- Sequential keybindings, e.g. Hyper-a,f for Finder a = hs.hotkey.modal.new({}, "F16") apps = { {'d', 'Twitter'}, {'f', 'Finder'}, {'s', 'Skype'}, } for i, app in ipairs(apps) do a:bind({}, app[1], function() launch(app[2]); a:exit(); end) end pressedA = function() a:enter() end releasedA = function() end k:bind({}, 'a', nil, pressedA, releasedA)

Shortcut to reload config

-- Shortcut to reload config ofun = function() hs.reload() hs.alert.show("Config loaded") k.triggered = true end k:bind({}, 'o', nil, ofun)

Other Ideas:

  • Toggle an app’s focus

  • Toggle last app

  • Example using the chooser