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

@ -199,3 +199,4 @@ brew "fd"
brew "git-delta" brew "git-delta"
brew "sn0int" brew "sn0int"
brew "prettier" brew "prettier"
brew "switchaudio-osx"

View File

@ -19,5 +19,13 @@ alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv $HOME/.Trash; s
# via https://github.com/richinfante/dotfiles/blob/0e1df2d833257e3a3ca2e4fcc8f2f128d52b5d29/dotfiles/.profile_setup/30-aliases.sh # via https://github.com/richinfante/dotfiles/blob/0e1df2d833257e3a3ca2e4fcc8f2f128d52b5d29/dotfiles/.profile_setup/30-aliases.sh
alias finder="open ." alias finder="open ."
alias cls="clear; printf '\e[3J'" alias cls="clear; printf '\e[3J'"
alias zoom="open -na 'zoom.us'" # Sound management
alias mute_headset='mute_device "Plantronics BT600"'
alias mute_speakers='mute_device "Haut-parleurs MacBook Pro"'
alias switch_headset='mute_speakers && switch_device "Plantronics BT600"'
alias switch_speakers='mute_headset && switch_device "Haut-parleurs MacBook Pro"'
# Meeting management
alias zoom="switch_headset && open -na 'zoom.us'"
alias nozoom="pkill 'zoom.us'" alias nozoom="pkill 'zoom.us'"
alias zoom30='zoomtimeboxed 30'
alias zoom60='zoomtimeboxed 60'

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") 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 # Web Crawling
function aboutpage() { function aboutpage() {
year=$(echo "$*" | egrep --extended-regexp --only-matching '\b[[:digit:]]{4}\b' H -n1) year=$(echo "$*" | egrep --extended-regexp --only-matching '\b[[:digit:]]{4}\b' H -n1)

View File

@ -9,15 +9,18 @@ attrs==19.3.0
Automat==0.8.0 Automat==0.8.0
autopep8==1.4.4 autopep8==1.4.4
backcall==0.1.0 backcall==0.1.0
beautifulsoup4==4.8.1 beautifulsoup4==4.9.1
beautysh==6.0.1 beautysh==6.0.1
black==19.10b0 black==19.10b0
bleach==3.1.4 bleach==3.1.4
bs4==0.0.1 bs4==0.0.1
cachetools==3.1.1 cachetools==3.1.1
certifi==2019.9.11 castero==0.8.0
certifi==2020.6.20
cffi==1.13.2 cffi==1.13.2
chardet==3.0.4 chardet==3.0.4
CJKwrap==2.2
click==7.1.2
colorama==0.4.1 colorama==0.4.1
colorzero==1.1 colorzero==1.1
configobj==5.0.6 configobj==5.0.6
@ -33,19 +36,19 @@ flake8==3.7.9
future==0.18.2 future==0.18.2
gitlint==0.13.1 gitlint==0.13.1
google-api-python-client==1.7.11 google-api-python-client==1.7.11
google-auth==1.7.0
google-auth-httplib2==0.0.3 google-auth-httplib2==0.0.3
google-auth==1.7.0
gpg==1.13.1 gpg==1.13.1
gpiozero==1.5.1 gpiozero==1.5.1
guizero==1.1.0 guizero==1.1.0
haxor-news==0.4.3 haxor-news==0.4.3
httplib2==0.18.0 httplib2==0.18.0
hyperlink==19.0.0 hyperlink==19.0.0
idna==2.8 idna==2.10
incremental==17.5.0 incremental==17.5.0
ipykernel==5.1.3 ipykernel==5.1.3
ipython==7.9.0
ipython-genutils==0.2.0 ipython-genutils==0.2.0
ipython==7.9.0
isort==4.3.21 isort==4.3.21
jedi==0.15.1 jedi==0.15.1
jmespath==0.9.4 jmespath==0.9.4
@ -75,11 +78,12 @@ pipenv==2018.11.26
pkginfo==1.5.0.1 pkginfo==1.5.0.1
pocket==0.3.6 pocket==0.3.6
prompt-toolkit==2.0.10 prompt-toolkit==2.0.10
proselint==0.10.2
Protego==0.1.15 Protego==0.1.15
psutil==5.7.0 psutil==5.7.0
ptyprocess==0.6.0 ptyprocess==0.6.0
pyasn1==0.4.7
pyasn1-modules==0.2.7 pyasn1-modules==0.2.7
pyasn1==0.4.7
pycodestyle==2.5.0 pycodestyle==2.5.0
pycparser==2.19 pycparser==2.19
PyDispatcher==2.0.5 PyDispatcher==2.0.5
@ -92,13 +96,15 @@ pyhcl==0.4.0
pylint==2.4.3 pylint==2.4.3
pyOpenSSL==19.0.0 pyOpenSSL==19.0.0
pyparsing==2.4.4 pyparsing==2.4.4
PyQt5==5.13.2
PyQt5-sip==12.7.0 PyQt5-sip==12.7.0
PyQt5==5.13.2
PyQtChart==5.13.1 PyQtChart==5.13.1
pyserial==3.4 pyserial==3.4
PySocks==1.7.1 PySocks==1.7.1
python-dateutil==2.8.0 python-dateutil==2.8.0
python-jenkins==1.5.0 python-jenkins==1.5.0
python-mpv==0.4.8
python-vlc==3.0.10114
pytz==2019.3 pytz==2019.3
PyYAML==5.1.2 PyYAML==5.1.2
pyzmq==18.1.0 pyzmq==18.1.0
@ -110,17 +116,18 @@ readme-renderer==24.0
rebound-cli==2.0.0 rebound-cli==2.0.0
regex==2019.11.1 regex==2019.11.1
relint==1.2.1 relint==1.2.1
requests==2.22.0
requests-futures==1.0.0 requests-futures==1.0.0
requests-toolbelt==0.9.1 requests-toolbelt==0.9.1
requests==2.24.0
rsa==3.4.2 rsa==3.4.2
rtv==1.27.0 rtv==1.27.0
Scrapy==1.8.0 Scrapy==1.8.0
semver==2.9.0 semver==2.9.0
service-identity==18.1.0 service-identity==18.1.0
sh==1.12.14 sh==1.12.14
six==1.15.0
slacker==0.13.0 slacker==0.13.0
soupsieve==1.9.5 soupsieve==2.0.1
stashy==0.6 stashy==0.6
stem==1.7.1 stem==1.7.1
toml==0.10.0 toml==0.10.0
@ -133,11 +140,11 @@ Twisted==19.7.0
twitter==1.18.0 twitter==1.18.0
typed-ast==1.4.0 typed-ast==1.4.0
uritemplate==3.0.0 uritemplate==3.0.0
urllib3==1.25.6 urllib3==1.25.9
urwid==2.0.1 urwid==2.0.1
vim-vint==0.3.21 vim-vint==0.3.21
virtualenv==16.7.7
virtualenv-clone==0.5.3 virtualenv-clone==0.5.3
virtualenv==16.7.7
w3lib==1.21.0 w3lib==1.21.0
wcwidth==0.1.7 wcwidth==0.1.7
webencodings==0.5.1 webencodings==0.5.1
@ -145,6 +152,3 @@ websocket-client==0.56.0
wrapt==1.11.2 wrapt==1.11.2
yamllint==1.23.0 yamllint==1.23.0
zope.interface==4.6.0 zope.interface==4.6.0
click==7.1.2
proselint==0.10.2
six==1.15.0