initial checkin
This commit is contained in:
commit
f4343686d3
|
@ -0,0 +1,9 @@
|
|||
# Overview
|
||||
|
||||
Quick applescript-wrapped-in-bash script to toggle ms teams mute remotely via ssh.
|
||||
|
||||
# Requirements
|
||||
- [bash](https://www.gnu.org/software/bash/)
|
||||
- [bashtools](https://git.nethack.net/rob/bashtools)
|
||||
- MS Teams (obviously)
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
#!/usr/bin/env bash
|
||||
. ${HOME}/code/bashtools/bashtools.sh
|
||||
if [[ -z $HAVE_BASHTOOLS ]]; then
|
||||
echo "ERROR: bashtools not installed download from https://git.nethack.net/rob/bashtools" >/dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
doit=0
|
||||
teamsapp="Microsoft Teams classic"
|
||||
|
||||
function usage() {
|
||||
echo "usage: $0 [-y] [\"Microsoft Teams Application Title\"]"
|
||||
echo
|
||||
echo "Toggles ms teams mic mute on/off."
|
||||
echo
|
||||
echo "Unless -y is used, script will run in test mode and not"
|
||||
echo "actually do anything."
|
||||
}
|
||||
|
||||
function maxof() {
|
||||
[[ -z $* ]] && return 1
|
||||
echo "$*" | tr ' ' '\n' | egrep '^[0-9]+$' | sort -n | tail -1
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
echo -e -n "$PLAIN"
|
||||
tput cnorm
|
||||
echo
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
if [[ $1 == *-h* ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
if [[ $1 == "-y" ]]; then
|
||||
doit=1
|
||||
shift
|
||||
fi
|
||||
if [[ -n $* ]]; then
|
||||
teamsapp="$*"
|
||||
fi
|
||||
|
||||
if [[ $doit -eq 1 ]]; then
|
||||
read -p "Is the mic currently muted? " yn
|
||||
[[ $yn == "y" ]] && mute=1 || mute=0
|
||||
else
|
||||
warn "Running in test mode. use -y to actually control mic."
|
||||
mute=0
|
||||
fi
|
||||
csecho "$CYAN" "Space to toggle, anything else to quit"
|
||||
txt=" "
|
||||
|
||||
col_recording="${ORANGE}${BOLD}"
|
||||
col_muted="${GREY}"
|
||||
|
||||
txt_recording="🎤 RECORDING 🎤"
|
||||
txt_muted="🔇 (muted) 🔇"
|
||||
n=$(maxof ${#txt_recording} ${txt_muted})
|
||||
n=$((n + 5))
|
||||
tput civis
|
||||
while [ 1 ]; do
|
||||
if [[ $mute -eq 0 ]]; then
|
||||
col="${col_recording}"
|
||||
txt="${txt_recording}"
|
||||
else
|
||||
col="${col_muted}"
|
||||
txt="${txt_muted}"
|
||||
fi
|
||||
echo -en '\r'
|
||||
printf "[${col}%-${n}s$PLAIN]" "$txt"
|
||||
read -s -N 1 -p "" dummy
|
||||
[[ $dummy != " " ]] && exit 0
|
||||
if [[ $doit -eq 1 ]]; then
|
||||
# Send shift+command+m to teams (toggle mute)
|
||||
#tell application "System Events"
|
||||
# set prev to name of 1st process whose frontmost is true
|
||||
#end tell
|
||||
|
||||
osascript << EOF
|
||||
tell application "System Events"
|
||||
tell application "${teamsapp}" to activate
|
||||
keystroke "m" using {shift down, command down}
|
||||
end tell
|
||||
EOF
|
||||
#tell application prev
|
||||
# activate
|
||||
#end tell
|
||||
fi
|
||||
mute=$((1 - $mute))
|
||||
done
|
||||
exit 1
|
Loading…
Reference in New Issue