Better HN
topnewbestaskshowjobs
Log inSign up

0rca

1 karma · joined Feb 21, 2014 (12y ago) · 1 submissions

Submissions

comment 3y ago · link · parent

For MacOS there is Hammerspoon, that provides immensely powerful scripting, but can merely open and close the apps, too.

  -- ~/.hammerspoon/init.lua
  function define_shortcut(appName, key, mod)
    hs.hotkey.bind(mod, key, function()
      hs.application.enableSpotlightForNameSearches(true)
      local app = hs.application.find(appName)
      if app and app:isFrontmost() then
        app:hide()
      else
        hs.application.open(appName)
      end
    end)
  end

  define_shortcut("Alacritty", "F1", {})
  define_shortcut("Firefox", "F2", {})