Skip to content

Instantly share code, notes, and snippets.

@343max
Last active October 8, 2021 11:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 343max/0ee74ba240574a111104fe079bf83170 to your computer and use it in GitHub Desktop.
Save 343max/0ee74ba240574a111104fe079bf83170 to your computer and use it in GitHub Desktop.
HammerSpoon script to toggle the mic in google meet meeting in chrome
  • get hammersponn: brew install --cask hammerspoon
  • drop the file into yout init.lua dir
  • import & bind in your init.lua:
local toggleGoogleMeetMic = require('google-meet-mic')
hs.hotkey.bind({"shift"}, "F16", toggleGoogleMeetMic)
local function toggleGoogleMeetMic()
local success, result, descriptor = hs.osascript.applescript('tell application "Google Chrome" to execute active tab of front window javascript "true"')
print(success)
if (success == false) then
hs.dialog.blockAlert('Chrome Error', descriptor["NSLocalizedFailureReason"])
return
end
local _, background = hs.osascript.applescript('tell application "Google Chrome" to execute active tab of front window javascript "window.getComputedStyle(document.querySelector(\'button[aria-label*=\\"⌘ + d\\"]\')).backgroundColor"')
print(background)
if (background == "rgb(234, 67, 53)") then
hs.alert.show('🎙 Microphone ON 🟢')
elseif (background == "rgb(60, 64, 67)") then
hs.alert.show('🎙 Microphone OFF 🚫')
else
hs.alert.show('🎙⚠️ Something went wrong (No meeting in active tab?)')
return
end
hs.osascript.applescript('tell application "Google Chrome" to execute active tab of front window javascript "document.querySelector(\'button[aria-label*=\\"⌘ + d\\"]\').click()"')
end
return toggleGoogleMeetMic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment