Skip to content

Instantly share code, notes, and snippets.

@LaughDonor
Last active May 9, 2024 23:32
Show Gist options
  • Save LaughDonor/cf018e3b9d41d6694c02de7c78f24038 to your computer and use it in GitHub Desktop.
Save LaughDonor/cf018e3b9d41d6694c02de7c78f24038 to your computer and use it in GitHub Desktop.
Kuando Omega BusyLight for Zoom on MacOS
busylight-for-humans
import asyncio
from subprocess import run
from sys import stderr
from busylight.lights.exceptions import LightUnavailable, NoLightsFound
from busylight.lights.kuando import Busylight_Omega
def muted_status():
output = run(["osascript", "zoomMicDetect.scpt"], capture_output=True)
if output.returncode:
raise Exception(f"Error: {output.stderr}")
return output.stdout.decode("utf-8").strip()
status = {
"1": (0, 255, 0),
"true": (255, 0, 0),
"false": (0, 255, 100),
"off": (0, 200, 0),
}
def light_off():
if light and light.is_pluggedin:
light.off()
def check_status():
global light
try:
light.update()
if light.is_pluggedin:
light.on(status[muted_status()])
else:
print("Light Disconnected", file=stderr)
except Exception as e:
print(e, file=stderr)
light_off()
async def get_light():
global light
while True:
try:
if light:
light.update()
if not light or light.is_unplugged:
light = Busylight_Omega.first_light()
if light.is_unplugged:
raise LightUnavailable()
except (NoLightsFound, LightUnavailable):
print("Light Unavailable/Disconnected", file=stderr)
await asyncio.sleep(2)
if light and light.is_pluggedin:
return
async def async_main():
while True:
await get_light()
check_status()
await asyncio.sleep(1)
if __name__ == "__main__":
global light
light = None
try:
asyncio.run(async_main())
except KeyboardInterrupt:
pass
finally:
light_off()
tell application "System Events"
if (get name of every application process) contains "zoom.us" then
tell application "System Events" to tell application process "zoom.us"
if menu item "Join Audio" of menu 1 of menu bar item "Meeting" of menu bar 1 exists then
return 1
else
if (menu item "Mute audio" of menu 1 of menu bar item "Meeting" of menu bar 1 exists) or (menu item "Mute telephone" of menu 1 of menu bar item "Meeting" of menu bar 1 exists) then
return true
else
if (menu item "Unmute audio" of menu 1 of menu bar item "Meeting" of menu bar 1 exists) or (menu item "Unmute telephone" of menu 1 of menu bar item "Meeting" of menu bar 1 exists) then
return false
else
return off
end if
end if
end if
end tell
else
return off
end if
end tell
return off
@LaughDonor
Copy link
Author

  1. Copy files to directory, and cd into it
  2. pip3 install -r requirements.txt
  3. python3 zoomMicDetect.py

May need to tell MacOS to give the script accessibility permissions.
Works on Zoom and ZoomGov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment