Skip to content

Instantly share code, notes, and snippets.

@darkfrank-it
Created August 11, 2022 15:14
Show Gist options
  • Select an option

  • Save darkfrank-it/6b6c72766fd1ebd28d045c4e0db431cd to your computer and use it in GitHub Desktop.

Select an option

Save darkfrank-it/6b6c72766fd1ebd28d045c4e0db431cd to your computer and use it in GitHub Desktop.
Toggle microphone + Toggle Microsoft Team mic. To select correct source use 'pactl subscribe' and then mute the target mic to get the correct id.
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-only
# Copyright (C) 2022 darkfrank-it
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the
# Free Software Foundation, version 3.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
pactl set-source-mute 54 toggle
WIN=$(xdotool search --onlyvisible --name 'microsoft teams$')
if [ -n "$WIN" ]; then
xdotool windowraise $WIN && sleep 0.1 && xdotool windowfocus $WIN && sleep 0.1 && xdotool key --window $WIN 'ctrl+shift+m'
fi
STATUS="$(pactl list sources | grep -A 10 'Source #54' | grep 'Mute: ' | sed -e 's/^[[:space:]]*//')"
if [ "$STATUS" = "Mute: no" ]; then
ICON="notification-microphone-sensitivity-high"
else
ICON="notification-microphone-sensitivity-muted"
fi
notify-send -a "Mic. Toggle" -i "$ICON" "$STATUS"
@darkfrank-it
Copy link
Author

Depends on xdotool, notify-send, pactl (PulseAudio)
It also fire a notification with the status of the microphone.
It not synchronize mic status with Teams, so you have to manually synchronize.
Tested on Lubuntu 22.04 with xfwm4.

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