Skip to content

Instantly share code, notes, and snippets.

@DavidMikeSimon
Created June 29, 2021 21:36
Show Gist options
  • Select an option

  • Save DavidMikeSimon/01a0668916008ad537e5868a7612a7e7 to your computer and use it in GitHub Desktop.

Select an option

Save DavidMikeSimon/01a0668916008ad537e5868a7612a7e7 to your computer and use it in GitHub Desktop.
My little Hammerspoon script for Zoom
-----------
-- Zoom PTT in Hammerspoon
-----------
function withZoomApp(fun)
local app = hs.application.get("zoom.us")
if (app ~= nil) then
fun(app)
end
end
function pttDown()
withZoomApp(function(app)
hs.eventtap.event.newKeyEvent("space", true):post(app)
end)
end
function pttUp()
withZoomApp(function(app)
hs.eventtap.event.newKeyEvent("space", false):post(app)
end)
end
function disconnect()
withZoomApp(function(app)
return app:selectMenuItem({"zoom.us", "Quit Zoom"})
end)
end
-- Let's use right-shift as a Zoom PTT key.
-- Can't use hotkey.bind to just watch modifier changes, so we use eventtap directly
zoomRightShiftPttListener = hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, function(event)
if (event:getKeyCode() == hs.keycodes.map['rightshift']) then
if (event:getFlags()['shift']) then
pttDown()
else
pttUp()
end
end
end)
zoomRightShiftPttListener:start()
-- If you want to use a regular (i.e. non-modifier) key for Zoom PTT, it's much simpler:
-- hs.hotkey.bind('', 'padenter', pttDown, pttUp)
hs.hotkey.bind('', 'pad1', disconnect)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment