Skip to content

Instantly share code, notes, and snippets.

@tobru
Created April 19, 2021 14:42
Show Gist options
  • Save tobru/68fe2a5ed80d828fd990ed67856ad052 to your computer and use it in GitHub Desktop.
Save tobru/68fe2a5ed80d828fd990ed67856ad052 to your computer and use it in GitHub Desktop.
Zoom Toggler
#!/bin/bash
set -eo pipefail
usage() {
echo "Usage: $0 <cmd>"
echo "Available commands:"
echo " * mic"
echo " * vid"
echo " * both"
echo " * leave"
exit 1
}
[[ -n "$1" ]] || usage $@
readonly currwind=$(xdotool getactivewindow)
readonly windowname="Zoom Meeting"
send_message() {
local msg=$1
notify-send -a "Zoom Toggler" -i Zoom "$msg"
}
exec_xdotool() {
local key=$1
local msg=$2
xdotool sleep 0.100 search --name "${windowname}" windowactivate --sync %1 key ${key} windowactivate "${currwind}"
if [ $? == 0 ] ; then
send_message "Zoom ${msg}"
else
send_message "Zoom ${msg} failed"
fi
}
case "$1" in
mic)
exec_xdotool "alt+a" "Mic Toggled"
;;
vid)
exec_xdotool "alt+v" "Cam Toggled"
;;
both)
exec_xdotool "alt+a" "Mic Toggled"
exec_xdotool "alt+v" "Cam Toggled"
;;
leave)
exec_xdotool "alt+q Return" "Left"
;;
*)
echo "Unknown command '$1' for $0"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment