system wide shortcut for Mac OS X

前端 未结 3 456
滥情空心
滥情空心 2020-12-10 09:27

So I was asked to port some internal helper applications to Mac OS X 10.7.

Works all quite welll as the platform dependent code is minimal anyhow, but one applicati

3条回答
  •  不思量自难忘°
    2020-12-10 09:43

    Why has nobody ever mentioned the hammerspoon, which supports custom global system shortcuts, which can invoke shell command or launch UI application like Safari, PHOTOSHOP.

    The following is an example written by me demonstrating how to invoke shell function with global hotkeys. https://gist.github.com/BigSully/0e59ab97f148bc167ea19dbd42ebef4b

    Use hs.execute to execute shell command, either non-interactive or interactive.

    hs.hotkey.bind({"cmd", "alt", "ctrl"}, "P", function()
      local output = hs.execute("toggleProxy", true)
      hs.alert.show(output)
    end)
    

    or Use hs.application.launchOrFocus to launch application hs.application.launchOrFocus("Safari")

提交回复
热议问题