Open the SwiftBar application.

On the first launch it will ask for the folder where you will save the scripts, so choose where you l like (I chose Documents/Swiftabar).

In that folder, add the following 2 AppleScript files.

zoomMuteState.500ms.scpt

#!/usr/bin/osascript

# zoomMuteState
# v1.0
# daidaidais
# daidaidais
# Zoom Mute State
# Applescript

# true
# true
# true
# true
# false

property btnTitle : "Mute Audio"

if application "zoom.us" is running then
	tell application "System Events"
		tell application process "zoom.us"
			if exists (menu bar item "Meeting" of menu bar 1) then
				if exists (menu item btnTitle of menu 1 of menu bar item "Meeting" of menu bar 1) then
					do shell script "if ls /dev/cu.usbmodem* &> /dev/null; then PORTS=$(ls /dev/cu.usbmodem*); echo audioON>$PORTS; fi"
					set returnValue to "􀊱 | color=red | symbolize=True"
				else
					do shell script "if ls /dev/cu.usbmodem* &> /dev/null; then PORTS=$(ls /dev/cu.usbmodem*); echo audioOFF>$PORTS; fi"
					set returnValue to "􀊳"
				end if
			else
				set returnValue to ""
				do shell script "if ls /dev/cu.usbmodem* &> /dev/null; then PORTS=$(ls /dev/cu.usbmodem*); echo audioOFF>$PORTS; fi"
			end if
		end tell
	end tell
else
	set returnValue to ""
end if

return returnValue & "| size=16
---
zoomMuteState"

zoomVideoState.500ms.scpt

#!/usr/bin/osascript

# zoomVideoState
# v1.0
# daidaidais
# daidaidais
# Zoom Video State
# Applescript

# true
# true
# true
# true
# false

property btnTitle : "Stop Video"

if application "zoom.us" is running then
	tell application "System Events"
		tell application process "zoom.us"
			if exists (menu bar item "Meeting" of menu bar 1) then
				if exists (menu item btnTitle of menu 1 of menu bar item "Meeting" of menu bar 1) then
					do shell script "if ls /dev/cu.usbmodem* &> /dev/null; then PORTS=$(ls /dev/cu.usbmodem*); echo videoON>$PORTS; fi"
					set returnValue to "􀍊 | color=red | symbolize=True"
				else
					do shell script "if ls /dev/cu.usbmodem* &> /dev/null; then PORTS=$(ls /dev/cu.usbmodem*); echo videoOFF>$PORTS; fi"
					set returnValue to "􀍎"
				end if
			else
				set returnValue to ""
				do shell script "if ls /dev/cu.usbmodem* &> /dev/null; then PORTS=$(ls /dev/cu.usbmodem*); echo videoOFF>$PORTS; fi"
			end if
		end tell
	end tell
else
	set returnValue to ""
end if

return returnValue & "| size=16
---
zoomVideoState"

These scripts scrape the Mac OS System Events to check if there’s anything named Meeting in the menu bar, and if yes then check if there’s any item named Stop Video or Mute Audio, which would indicate the mute/video status on Zoom. It would also then run a shell script to check if there’s anything in ls /dev/cu.usbmodem*, which is the port for Arduino based devices, and if yes then communicate the mute/video status via the serial port.

Note: the naming of files in SwiftBar is important. The .500ms. means that it will refresh every 1 second

This script is a combination of my googling, Chromatic’s article and nickjvturner’s code.

If the icons are not showing up properly, open the SF Symbols app that you installed, search the icon that you want to use (e.g. mic.fill), right click it and select Copy Symbol, then paste it to wherever it says

set returnValue to "*paste here* | color=red | symbolize=True"

in the AppleScript.

Leave a Reply