InternetmacOSTutorials

How to add a global mute (and un-mute) button for Microsoft Teams on macOS

The problem

Do you know the problem when you're in a Microsoft Teams call, you are on mute and working on something. Suddenly a question comes in, and you have to search for the Teams window and trying to find the unmute button.

The Solution

Here is a little script for macOS that does the following:

  • Adds a menubar icon you can click to bring the Teams window to the foreground
  • Adds a menubar text you can click to toggle mute on Teams, even if its somewhere in the background
  • Adds the global shortcut Ctrl-§ which also toggles mute on Teams globally

Notice:

If Teams is minimized, the buttons and shortcut don't work, so just alt-tab out of Teams, don't minimize it.

As a little bonus, it will also toggle mute on Zoom if you use that.

Installation

Install Hammerspoon: https://www.hammerspoon.org

Start it, and open the config:

It will open the empty init.lua file in your editor. Add the following snippet:

-- Mute Button
local muteButton = hs.menubar.new()
muteButton:setTitle("Mute Toggle")

function toggleMute() 
  local teams = hs.application.find("com.microsoft.teams")
  if not (teams == null) then
    hs.eventtap.keyStroke({"cmd","shift"}, "m", 0, teams)
  end
  
  -- While we're at it, also support zoom
  local zoom = hs.application.find("us.zoom.xos")
   if not (zoom == nil) then
    hs.eventtap.keyStroke({"cmd","shift"}, "a", 0, zoom)
  end

end

muteButton:setClickCallback(toggleMute)

-- Edit here, if you want other modifiers or a different hotkey:
-- Example: local modifiers = {"cmd", "alt", "ctrl", "shift"}
--          hs.hotkey.bind(modifiers, "a", toggleMute)
local modifiers = {"ctrl"}
hs.hotkey.bind(modifiers, "§", toggleMute)


-- Teams Show Button
local teamsShowButton = hs.menubar.new()
local logo = hs.image.imageFromAppBundle("com.microsoft.teams")
logo:size({w=16,h=16})
teamsShowButton:setIcon(logo)

function showTeams() 
  local teams = hs.application.find("com.microsoft.teams")
  if not (teams == null) then
    teams:activate()
  end
end

teamsShowButton:setClickCallback(showTeams)

Reload the config:

Then you will have two now buttons on your menubar:

The icon is to bring Teams to the foreground, "Mute Toggle" is to toggle the mute function on Teams.

You may also like

Comments are closed.

More in:Internet