local status, hyperModeAppMappings = pcall(require, 'keyboard.hyper-apps')

if not status then
  hyperModeAppMappings = require('keyboard.hyper-apps-defaults')
end

for i, mapping in ipairs(hyperModeAppMappings) do
  hs.hotkey.bind({'shift', 'ctrl', 'alt', 'cmd'}, mapping[1], function()
    hs.application.launchOrFocus(mapping[2])
  end)
end

local status, hyperModeAppMappings = pcall(require, 'keyboard.hyper-apps')

if not status then
  hyperModeAppMappings = require('keyboard.hyper-apps-defaults')
end

for i, mapping in ipairs(hyperModeAppMappings) do
  hs.hotkey.bind({'shift', 'ctrl', 'alt', 'cmd'}, mapping[1], function()
    local appName = mapping[2]
    local app = hs.application.get(appName)
    if app then
      app:activate()
    else
      hs.application.launchOrFocus(appName)
    end
  end)
end

Fix "launchOrFocus" behavior for Atom
Fix "launchOrFocus" behavior for Atom

Some time in the last few weeks, something seems to have changed such
that Hyper+E always opens a *new* Atom instance, even when there's
already an exising Atom instance running. I would expect
hs.application.launchOrFocus to focus the currently-running Atom
instance, but that's not happening for some reason. This change seems to
be a successful workaround for this issue.
