Last active
March 17, 2021 19:12
-
-
Save lyallcooper/d734c8b8fcf1f2e521a8f0d986a6c3ee to your computer and use it in GitHub Desktop.
AppleScript for getting the current audio/video mute status of Google Meet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript | |
-- Use this script in conjunction with a tool like xbar (https://github.com/matryer/xbar) to add | |
-- an audio/video mute status indicator to the menu bar. | |
-- | |
-- ATTN: Make sure View > Developer > "Allow JavaScript from Apple Events" is enabled in Chrome | |
set separator to "\n---\n" | |
tell application "Google Chrome" | |
repeat with w in (windows) | |
set i to 1 -- tabs are not zero indexed | |
repeat with t in (tabs of w) | |
if URL of t starts with "https://meet.google.com/" then | |
tell tab i of w | |
set inMeet to (execute javascript "document.querySelectorAll('[aria-label=\"Leave call\"]').length === 1") | |
if inMeet then | |
set videoActive to (execute javascript "document.querySelectorAll('[aria-label=\"Turn off camera (⌘ + e)\"]').length === 1") | |
set audioActive to (execute javascript "document.querySelectorAll('[aria-label=\"Turn off microphone (⌘ + d)\"]').length === 1") | |
if audioActive and videoActive then | |
return "AV" & separator & "Audio and Video Active" | |
else if audioActive then | |
return "A" & separator & "Audio Active Only" | |
else if videoActive then | |
return "V" & separator & "Video Active Only" | |
else | |
return "✕" & separator & "Audio and Video Muted" | |
end if | |
end if | |
end tell | |
end if | |
set i to i + 1 | |
end repeat | |
end repeat | |
end tell | |
return "∅" & separator & "No Active Meet Found" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment