feature: manage macos sound devices

- installed switchaudio-osx for managing macos sound devices
  e.g : muting a device or switching to a device
- aliases/functions to switch/mute devices
- always mute speakers and switch to headset before running a zoom
  session
- new aliases for starting timeboxed zoom meetings
This commit is contained in:
MorganGeek
2020-07-19 15:41:26 +02:00
parent 34254c50d5
commit 447698b826
4 changed files with 60 additions and 15 deletions

View File

@ -174,6 +174,38 @@ function suggest_aliases() {
done < <(top_commands_full "" "$search_input_size" | awk '{ $1=""; $2=""; $3=""; print}' | awk 'NF' | awk '{$1=$1};1' | awk -v COUNT=1 'NF>COUNT' H "-$search_input_size")
}
# Sound management
# Inspired by https://apple.stackexchange.com/a/213048/231885 for switching devices
# and https://coderwall.com/p/22p0ja/set-get-osx-volume-mute-from-the-command-line for volume management
function mute_device() {
local current_device=$(SwitchAudioSource -c)
local target_device="$1"
if SwitchAudioSource -a | grep "$target_device" 1>/dev/null; then
SwitchAudioSource -s "$1" 1>/dev/null
osascript -e 'set volume output muted true'
success "device $target_device muted"
SwitchAudioSource -s "$current_device" 1>/dev/null
if [ "$current_device" != "$target_device" ]; then
arrow "switching back to $current_device"
fi
arrow "currently using $target_device"
else
error "sound device not found : $target_device (maybe it's disconnected ?)"
fi
}
function switch_device() {
local target_device="$1"
if SwitchAudioSource -a | grep "$target_device" 1>/dev/null; then
if SwitchAudioSource -s "$1" 1>/dev/null; then
success "switched to $target_device"
else
error "failed to switch to $target_device"
fi
else
error "sound device not found : $target_device (maybe it's disconnected ?)"
fi
}
# Web Crawling
function aboutpage() {
year=$(echo "$*" | egrep --extended-regexp --only-matching '\b[[:digit:]]{4}\b' H -n1)